This was my policy until now: - if an action needed to do a mode conversion, it was allow to do so. However it should exclude any case where it is not necessary. For example for the variable border, the action should not convert to RGBA in case of positive pixel border and in case of negative pixel border when the opaqueness is 100% - conversions back to the original mode should indeed occur in the save action. Right now the save action still need some work for converting to a P mode, but Nadia is working on this: https://bugs.launchpad.net/phatch/+bug/381379
So the save action should take care of converting to a mode which is supported by the file type if necessary. I'd would not like to convert by default in the beginning to RGBA as that might be unnecessary for many action lists, increase the memory and convert images which shouldn't be converted. Best regards, Stani On Tue, Jun 2, 2009 at 12:40 AM, Nadia Alramli <[email protected]> wrote: > Hey, > > I was thinking maybe it's not a good idea for each action to handle 'RGBA' > to 'P' conversion on its own. There are many actions that deal with > transparency and convert the images to 'RGBA'. To name a few: highlight, > color to alpha, mask. It is better to leave the 'RGBA' to 'P' conversion to > the save action, unless we have to. Or else the performance will suffer > because of all the overhead of repeating the same conversion in every > action. > > Best Regards, > Nadia > > On Mon, Jun 1, 2009 at 10:34 PM, Nadia Alramli <[email protected]> wrote: >> >> Hey Erich, >> >> Sorry, It took me sometime to get back to you on this. I needed to play >> with convert a bit to make sure I have the right answer. >> >>> >>> In PIL.Image.Image._new, which is what actually provides the new image >>> when convert() is called, a type 'P' Image object will be assigned a new >>> color palette. This color palette has no relation to the color palette of >>> the actual image. (I consider this to be a very serious bug in PIL). >> >> I agree, those bugs are really annoying. >> >>> >>> So what I do is get the palette from the converted image, and assign >>> that to the Image.palette.palette. >>> >>> >>> >>> Secondly, since the color palette is most likely different after hte >>> conversion, a simple index will not work. Instead save the transparent color >>> value by looking up the index for it in the original palette. When the new >>> palette is assigned, I then search for the transparent color value and save >>> the appropriate index in the info['transparency'] attribute. >> >> I can see a possible issue here. The colors in the palette are not >> necessaryly unique. So it is possible to match the wrong index. In my >> opinion a simpler solution is to create the new image in mode 'RGBA' instead >> of 'RGB'. The GIF transparency will be kept this way. Then to convert from >> RGBA to P you can use the updated solution here: >> http://nadiana.com/pil-tips-converting-png-gif#Thesolution >> I updated the article with a much better solution. I discovered it today >> while playing with convert to find a solution for your issue. >> >> I'm glad to have you in our team :) >> >> Regards, >> Nadia >> > > -- Phatch Photo Batch Processor - http://photobatch.stani.be SPE Python IDE - http://pythonide.stani.be _______________________________________________ Mailing list: https://launchpad.net/~phatch-dev Post to : [email protected] Unsubscribe : https://launchpad.net/~phatch-dev More help : https://help.launchpad.net/ListHelp

