After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 551231 - No transparency data is saved in the image data section of PSD files
No transparency data is saved in the image data section of PSD files
Status: RESOLVED FIXED
Product: GIMP
Classification: Other
Component: Plugins
git master
Other All
: Normal minor
: 2.6
Assigned To: GIMP Bugs
GIMP Bugs
Depends on:
Blocks:
 
 
Reported: 2008-09-07 14:46 UTC by Dennis Ranke
Modified: 2008-09-08 20:42 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
A patch to add writing of transparency data to the PSD export plugin (8.92 KB, patch)
2008-09-07 14:49 UTC, Dennis Ranke
needs-work Details | Review
Write transparency data, now using gimp_layer_new_from_visible (8.12 KB, patch)
2008-09-07 17:45 UTC, Dennis Ranke
none Details | Review
patch with some minor cleanups (8.01 KB, patch)
2008-09-08 19:24 UTC, Sven Neumann
none Details | Review
fixed patch with some minor cleanups (8.08 KB, patch)
2008-09-08 20:29 UTC, Dennis Ranke
committed Details | Review

Description Dennis Ranke 2008-09-07 14:46:04 UTC
Please describe the problem:
The PSD image data section contains the merge of the visible layers plus any extra channels. GIMP only writes the the color data of the merged layers here, not the alpha.
Applications (like GIMP of Photoshop) that support layers won't care for this ommission, because they re-create the alpha information from the layers, anyway. But for applications that only read the image data, it would be helpful to include the alpha just like Photoshop does.

Steps to reproduce:
1. Create or load any image that contains any transparent pixels
2. Save the image as PSD
3. Check the layer count in the PSD, ex. using a printf in the import plugin (num_layers < 0 => transparency channel follows color channels)


Actual results:
The resulting PSD does not contain transparency information in the image data section (num_layers > 0).

Expected results:
The resulting PSD does contain transparency information in the image data section. (num_layers < 0)

Does this happen every time?
Yes

Other information:
I have created a patch to write transparency. I'll attach it to this bug.
Comment 1 Dennis Ranke 2008-09-07 14:49:07 UTC
Created attachment 118224 [details] [review]
A patch to add writing of transparency data to the PSD export plugin
Comment 2 Sven Neumann 2008-09-07 17:12:07 UTC
If you need access to the image projection (a merged view of the image), please do not duplicate the image and merge or flatten it. Instead you should use gimp_layer_new_from_visible(). You don't even need to add that layer to the image if all you need is access to the pixel data. Just don't forget to delete it later.
Comment 3 Dennis Ranke 2008-09-07 17:45:29 UTC
Created attachment 118237 [details] [review]
Write transparency data, now using gimp_layer_new_from_visible
Comment 4 Sven Neumann 2008-09-08 19:24:41 UTC
Created attachment 118321 [details] [review]
patch with some minor cleanups

Thanks. Could you please test if this cleaned up version of your patch works as expected?
Comment 5 Dennis Ranke 2008-09-08 20:29:05 UTC
Created attachment 118326 [details] [review]
fixed patch with some minor cleanups

Thanks for the cleanup. You have missed two things in the create_merged_image function, though:
1. The test for transparency should be "if (alpha < 255)", not "if (alpha)"
2. inside the if, transparency_found has to be set to TRUE
This patch corrects those two things. Other than that, it's identical to yours.
Comment 6 Sven Neumann 2008-09-08 20:42:41 UTC
Ooops, sorry, I should have paid more attention when modifying your code. Thanks for spotting these mistakes. I have now committed this to trunk:

2008-09-08  Sven Neumann  <sven@gimp.org>

	* plug-ins/file-psd/psd-save.c: applied patch from Dennis Ranke as
	attached to bug #551231. Changes the PSD save plug-in to store
	transparency data in the image data section. Also fixes bug #551232
	(saving an indexed image with multiple layers as PSD modifies the
	image).