GNOME Bugzilla – Bug 551231
No transparency data is saved in the image data section of PSD files
Last modified: 2008-09-08 20:42:41 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.
Created attachment 118224 [details] [review] A patch to add writing of transparency data to the PSD export plugin
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.
Created attachment 118237 [details] [review] Write transparency data, now using gimp_layer_new_from_visible
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?
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.
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).