Skip to content

Commit

Permalink
feat(psd): Add support for 16- and 32-bit Photoshop file reads (#4208)
Browse files Browse the repository at this point in the history
As mentioned in #4205, #3900 and
#3910 (reply in thread)
OpenImageIO previously did not support reading of 16- and 32-bit files
beyond their merged image data section. I have now implemented this by:

1. Adding support for reading layer info from the "Lr16" and "Lr32"
Tagged Blocks as well as adding additional checks to the regular layer
info section
2. Implemented the Zip and ZipPrediction compression codec which is
required to read these files as that is photoshops preferred compression
codec for those bitdepths

Due to the way the Zip data is stored (per channel but not per scanline)
the current implementation reads the whole channel into a buffer which
is then memcpy'd from by calls to `read_native_scanline()`. The buffer
gets cleared on deletion of the `PSDInput` object

---------

Signed-off-by: EmilDohne <[email protected]>
Signed-off-by: Larry Gritz <[email protected]>
Co-authored-by: Larry Gritz <[email protected]>
  • Loading branch information
EmilDohne and lgritz authored Apr 2, 2024
1 parent 2ba88a7 commit fc5a454
Show file tree
Hide file tree
Showing 9 changed files with 895 additions and 46 deletions.
359 changes: 317 additions & 42 deletions src/psd.imageio/psdinput.cpp

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions testsuite/psd-colormodes/ref/out.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ Comparing "pattern2-16-rgb.psd.tif" and "ref/pattern2.tif"
PASS
Comparing "pattern2-8-cmyk.psd.tif" and "ref/pattern2-cmyk.tif"
PASS
Comparing "pattern2-16-cmyk.psd.tif" and "ref/pattern2-cmyk.tif"
Comparing "pattern2-16-cmyk.psd.tif" and "ref/pattern2-16-cmyk.psd.tif"
PASS
Comparing "pattern2-8-multichannel.psd.tif" and "ref/pattern2.tif"
PASS
Comparing "pattern2-16-multichannel.psd.tif" and "ref/pattern2.tif"
PASS
Comparing "pattern2-8-grayscale.psd.tif" and "ref/pattern2-gray.tif"
PASS
Comparing "pattern2-16-grayscale.psd.tif" and "ref/pattern2-gray.tif"
Comparing "pattern2-16-grayscale.psd.tif" and "ref/pattern2-16-grayscale.psd.tif"
PASS
Comparing "pattern2-8-indexed.psd.tif" and "ref/pattern2-alpha.tif"
PASS
Expand Down
Binary file not shown.
Binary file not shown.
573 changes: 571 additions & 2 deletions testsuite/psd/ref/out.txt

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions testsuite/psd/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,8 @@
command += info_command ("src/crash-psd-exif-1632.psd", failureok = 1)
# Corrupted thumbnail clobbered memory
command += info_command ("src/crash-thumb-1626.psd", failureok = 1)

# Test more modern (Photoshop 2023 files) with 16- and 32-bit files containing multiple sublayers
command += info_command ("src/Layers_8bit_RGB.psd")
command += info_command ("src/Layers_16bit_RGB.psd")
command += info_command ("src/Layers_32bit_RGB.psd")
Binary file added testsuite/psd/src/Layers_16bit_RGB.psd
Binary file not shown.
Binary file added testsuite/psd/src/Layers_32bit_RGB.psd
Binary file not shown.
Binary file added testsuite/psd/src/Layers_8bit_RGB.psd
Binary file not shown.

0 comments on commit fc5a454

Please sign in to comment.