Skip to content

Commit

Permalink
feat(psd): Add support for 16- and 32-bit Photoshop file reads (Acade…
Browse files Browse the repository at this point in the history
…mySoftwareFoundation#4208)

As mentioned in AcademySoftwareFoundation#4205, AcademySoftwareFoundation#3900 and
AcademySoftwareFoundation#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 <86836589+EmilDohne@users.noreply.github.com>
Signed-off-by: Larry Gritz <lg@larrygritz.com>
Co-authored-by: Larry Gritz <lg@larrygritz.com>
  • Loading branch information
EmilDohne and lgritz committed Apr 2, 2024
1 parent 8e592e9 commit 0101781
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 0101781

Please sign in to comment.