Bug 338470

Summary: Support Photoshop/Adobe TIFF extensions.
Product: [Applications] krita Reporter: Raghavendra kamath <raghu>
Component: File formatsAssignee: amyspark <amy>
Status: RESOLVED FIXED    
Severity: wishlist CC: amy, analoguecolour, eneeen, halla, paulgeraskin, raghu, rylleman
Priority: NOR    
Version First Reported In: 2.8.1   
Target Milestone: ---   
Platform: Ubuntu   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: tiff file withlayers having various blend modes prepared in photoshop cc 2014
Krita does not import layers from tiff

Description Raghavendra kamath 2014-08-22 10:45:59 UTC
Cannot see layers of a layered tiff file when opened in krita.
also when i save a tiff file with layers from krita and reopen it in krita the blend modes are normal for the layers.
Comment 1 Halla Rempt 2014-08-22 10:47:34 UTC
Thanks for the report! Could you attach a multi-layer tiff file you created in another application? Please also specify which application that was. I'll check whether tiff actually supports different blend modes.
Comment 2 Halla Rempt 2014-08-23 09:27:30 UTC
I checked in the meantime with photoshop cs2, but I have to check with the spec to see what they are doing and what we are doing... 

http://partners.adobe.com/public/developer/tiff/index.html
Comment 3 Raghavendra kamath 2014-08-23 11:42:04 UTC
Created attachment 88386 [details]
tiff file withlayers having various blend modes prepared in photoshop cc 2014

Boudewijn Rempt please find attached tiff file.
it is created in photoshop cc 2014. i contains layers having blend modes like screen and normal

thank you
Comment 4 David 2015-06-01 12:14:56 UTC
It seems Photoshop is creating custom layer info tags in tiffs...

Many of the applications I've tried complains about:
TIFFReadDirectory: Warning, Unknown field with tag 37724 (0x935c) encountered.
TIFFFetchNormalTag: Warning, Incompatible type for "RichTIFFIPTC"; tag ignored.

ImageMagick claims to have just solved this in 6.9.1-4 but I haven't been able to try it myself.
http://www.imagemagick.org/discourse-server/viewtopic.php?t=26785 (Also much info in that thread)
Comment 5 Halla Rempt 2015-06-01 12:23:30 UTC
Ah, that's interesting. Thanks for the link!
Comment 6 Halla Rempt 2015-12-07 14:53:33 UTC
*** Bug 355911 has been marked as a duplicate of this bug. ***
Comment 7 Halla Rempt 2016-01-24 15:50:37 UTC
WISHGROUP: Stretchgoal
Comment 8 Halla Rempt 2017-03-02 10:17:52 UTC
*** Bug 377094 has been marked as a duplicate of this bug. ***
Comment 9 Halla Rempt 2017-12-10 08:21:29 UTC
*** Bug 387751 has been marked as a duplicate of this bug. ***
Comment 10 Raghavendra kamath 2019-04-18 12:02:49 UTC
The darktable dev has added layered tiff support for GIMP, can we take a look at it for our reference - https://twitter.com/GIMP_Official/status/1118811319036252160
Comment 11 Halla Rempt 2019-04-18 13:04:24 UTC
Is that photoshop-like tiff, or standard layered tiff, like we already support?
Comment 12 Paul Geraskin 2019-08-21 09:18:23 UTC
Created attachment 122273 [details]
Krita does not import layers from tiff

Krita does not import layers from tiff
Comment 13 Paul Geraskin 2019-08-21 09:19:53 UTC
Hi. Krita does not import layers from tiff. The tiff was made in PS.
I attached my file.
https://bugs.kde.org/attachment.cgi?id=122273
Comment 14 Halla Rempt 2019-08-21 09:28:44 UTC
Yes, Krita doesn't import layers from tiffs made in PS. That is what this wish is all about.
Comment 15 David 2019-08-21 09:52:19 UTC
Gimp (as well as Krita) still opens photoshop tiffs flattened. (Gimp 2.10.12). The tweet says "support for layers exporting to TIFF" (So export, no import)

Imagemagick does read the layers.
A convert saves the layers separately as images
convert ret.tif ret-test.png
(ImageMagick 6.9.7-4 Q16 x86_64 20170114)
Comment 16 Raghavendra kamath 2019-08-21 10:18:40 UTC
In the recent master, saving to multi layers tiff file from krita is not working.
Comment 17 Halla Rempt 2019-08-21 10:55:45 UTC
Works here when I uncheck "flatten image".
Comment 18 Raghavendra kamath 2019-08-21 11:05:19 UTC
Yes , sorry for false alarm it works now, :(
Comment 19 Bug Janitor Service 2021-07-06 12:55:56 UTC
A possibly relevant merge request was started @ https://invent.kde.org/graphics/krita/-/merge_requests/944
Comment 20 Halla Rempt 2021-08-23 13:11:48 UTC
Git commit 2dc3df63a8ad52468afd2a8a8f1123d4c080627d by Halla Rempt, on behalf of L. E. Segovia.
Committed on 23/08/2021 at 13:11.
Pushed by rempt into branch 'master'.

TIFF: add support for reading Photoshop layers and metadata

This commit builds upon the previous work in order to enable loading
the PSD-like layer data and metadata from the TIFFTAG_IMAGESOURCEDATA
and TIFFTAG_PHOTOSHOP fields.

Of special relevance are the following:

TIFFTAG_IMAGESOURCEDATA is a sequence of Layr/Lr16/Lr32 layer block,
followed by LMsk (which is Adobe's take on a global mask info block),
followed by Patt and Anot. As these are a byte-by-byte equivalent
of the PSD's additional layer info blocks, for TIFF I've added a logic
path that takes advantage of Lr16/32 and handles them all as additional
logic blocks safely. It must also be noted that these are globally
aligned to 4-byte boundaries, which do *not* apply to internal blocks
(see Layr), and they are also in *the endianness of the container* (this
is the reason why I added endianness handling in previous commits).

TIFFTAG_PHOTOSHOP is just a concatenation of resource blocks (as opposed
to a full resource section), but unlike the previous, it's in big endian
like its PSD sibling.

M  +31   -2    libs/psd/psd_additional_layer_info_block.cpp
M  +3    -0    libs/psd/psd_additional_layer_info_block.h
M  +1    -0    libs/psd/psd_header.cpp
M  +1    -0    libs/psd/psd_header.h
M  +2    -1    libs/psd/psd_layer_record.cpp
M  +116  -28   libs/psd/psd_layer_section.cpp
M  +4    -1    libs/psd/psd_layer_section.h
M  +121  -60   libs/psd/psd_pixel_utils.cpp
M  +13   -3    libs/psd/psd_pixel_utils.h
M  +1    -1    libs/psdutils/psd_utils.h
M  +5    -3    plugins/impex/tiff/CMakeLists.txt
M  +360  -60   plugins/impex/tiff/kis_tiff_converter.cc
M  +44   -3    plugins/impex/tiff/kis_tiff_converter.h
A  +99   -0    plugins/impex/tiff/kis_tiff_psd_layer_record.cpp     [License: GPL(v2.0+)]
A  +53   -0    plugins/impex/tiff/kis_tiff_psd_layer_record.h     [License: GPL(v2.0+)]
A  +276  -0    plugins/impex/tiff/kis_tiff_psd_resource_record.cpp     [License: GPL(v2.0+)]
A  +170  -0    plugins/impex/tiff/kis_tiff_psd_resource_record.h     [License: GPL(v2.0+)]

https://invent.kde.org/graphics/krita/commit/2dc3df63a8ad52468afd2a8a8f1123d4c080627d