Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 12 additions & 34 deletions src/doc/imageoutput.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1438,41 +1438,19 @@ without alteration while modifying the image description metadata:

.. tabs::

.. code-tab:: c++

// Open the input file
auto in = ImageInput::open ("input.jpg");

// Make an output spec, identical to the input except for metadata
ImageSpec out_spec = in->spec();
out_spec.attribute ("ImageDescription", "My Title");

// Create the output file and copy the image
auto out = ImageOutput::create ("output.jpg");
out->open ("output.jpg", out_spec);
out->copy_image (in);

// Clean up
out->close ();
in->close ();

.. code-tab:: py
.. tab:: C++
.. literalinclude:: ../../testsuite/docs-examples-cpp/src/docs-examples-imageoutput.cpp
:language: c++
:start-after: BEGIN-imageoutput-copy
:end-before: END-imageoutput-copy
:dedent: 4

# Open the input file
inp = ImageInput.open ("input.jpg")

# Make an output spec, identical to the input except for metadata
out_spec = inp.spec()
out_spec.attribute ("ImageDescription", "My Title")

# Create the output file and copy the image
out = ImageOutput.create ("output.jpg")
out.open ("output.jpg", out_spec)
out.copy_image (inp)

# Clean up
out.close ()
inp.close ()
.. tab:: Python
.. literalinclude:: ../../testsuite/docs-examples-python/src/docs-examples-imageoutput.py
:language: py
:start-after: BEGIN-imageoutput-copy
:end-before: END-imageoutput-copy
:dedent: 4



Expand Down
1 change: 1 addition & 0 deletions testsuite/docs-examples-cpp/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
command += run_app("cmake -E copy " + test_source_dir + "/../common/checker_with_alpha.exr checker_with_alpha.exr")
command += run_app("cmake -E copy " + test_source_dir + "/../common/unpremult.tif unpremult.tif")
command += run_app("cmake -E copy " + test_source_dir + "/../common/bayer.png bayer.png")
command += run_app("cmake -E copy " + test_source_dir + "/../common/grid-small.exr input.exr")

command += oiio_app("oiiotool") + "--pattern fill:top=0:bottom=1 256x256 1 -o mono.exr > out.txt ;"

Expand Down
25 changes: 25 additions & 0 deletions testsuite/docs-examples-cpp/src/docs-examples-imageoutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,36 @@ tiles_write()



void
copy_write()
{
// BEGIN-imageoutput-copy
// Open the input file
auto in = ImageInput::open("input.exr");

// Make an output spec, identical to the input except for metadata
ImageSpec out_spec = in->spec();
out_spec.attribute("ImageDescription", "My Title");

// Create the output file and copy the image
auto out = ImageOutput::create("output.exr");
out->open("output.exr", out_spec);
out->copy_image(in.get());

// Clean up
out->close();
in->close();
// END-imageoutput-copy
}



int
main(int /*argc*/, char** /*argv*/)
{
simple_write();
scanlines_write();
tiles_write();
copy_write();
return 0;
}
1 change: 1 addition & 0 deletions testsuite/docs-examples-python/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
command += run_app("cmake -E copy " + test_source_dir + "/../common/checker_with_alpha.exr checker_with_alpha.exr")
command += run_app("cmake -E copy " + test_source_dir + "/../common/unpremult.tif unpremult.tif")
command += run_app("cmake -E copy " + test_source_dir + "/../common/bayer.png bayer.png")
command += run_app("cmake -E copy " + test_source_dir + "/../common/grid-small.exr input.exr")

command += oiio_app("oiiotool") + "--pattern fill:top=0:bottom=1 256x256 1 -o mono.exr > out.txt ;"

Expand Down
22 changes: 22 additions & 0 deletions testsuite/docs-examples-python/src/docs-examples-imageoutput.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,32 @@ def tiles_write() -> None:
# END-imageoutput-tiles


def copy_write() -> None:
from OpenImageIO import ImageInput, ImageOutput

# BEGIN-imageoutput-copy
# Open the input file
inp = ImageInput.open("input.exr")

# Make an output spec, identical to the input except for metadata
out_spec = inp.spec()
out_spec.attribute("ImageDescription", "My Title")

# Create the output file and copy the image
out = ImageOutput.create("output.exr")
out.open("output.exr", out_spec)
out.copy_image(inp)

# Clean up
out.close()
inp.close()
# END-imageoutput-copy


if __name__ == '__main__':
# Each example function needs to get called here, or it won't execute
# as part of the test.
simple_write()
scanlines_write()
tiles_write()
copy_write()
Loading