← Back to team overview

phatch-dev team mailing list archive

Re: variable border action

 

On Tue, Jun 2, 2009 at 11:56 AM, Nadia Alramli <nadiana@xxxxxxxxx> wrote:
> Hi,
>
>> 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%
>
> I agree it is that case in most situations. But what if the original image
> mode was 'P' with transparency?
See my comment later on.

> The easiest solution to keep transparency in
> this case is to convert to 'RGBA' and keep it this way. Otherwise we have to
> replicate the save action conversion functionality and convert back to 'P'
> while keeping transparency. I think performance here matters more than
> memory.
I agree. Once you converted in action, you don't convert back.
Converting in actions is one-way. The save conversion functionality
should not be replicated in any action.

> I agree we should only convert when we have to. And only convert back to 'P'
> if absolutely necessary. In this case the border action can convert to
> 'RGBA' if the border is negative
I agree
> or if the image was mode 'p' with
> transparency.
As I didn't dive as deep in the subject as you, maybe I am forgetting
something. Let's consider the case where the image has mode 'P' and
transparency set. I thought it could be possible to keep the
transparency color index (stored inside photo.info['transparency'])
and add the border color to the palette (in case it was not part of it
already). This will only fail if the palette has 255 colors (+1 for
transparency) already, in which case a conversion to RGBA is needed by
a lack of colors in the palette, but not by transparency. (Note that
this would also be case for non transparent P images which have
already 256 colors and to which e.g. the variable border action wants
to add a color.)

One other reason to limit hidden conversions to a minimum, is that
less experienced users don't expect and experienced users will be very
critical against it if they think there is no reason to do so.

But as I said, I might overlook something. So I am very curious to
your reaction ;-)

Stani

-- 
Phatch Photo Batch Processor - http://photobatch.stani.be
SPE Python IDE - http://pythonide.stani.be



Follow ups

References