librelist archives

« back to archive

composite -blend with wand

composite -blend with wand

From:
mickael
Date:
2012-12-07 @ 21:17
Hi all,

I want to do with wand something equivalent to the ImageMagick command
"composite -blend 30 base.jpg input.jpg output.jpg"

I tried to do :
>-background = Image(filename=base.jpg)
>-im = Image(filename=input.jpg)
>-im.alpha_channel = True
>-im.transparentize(0.3)
>-background.composite(im, 0, 0)
>-im.save(filename=output.jpg)

but the transparentize does not seem to work as expected, and the result 
is the input.jpg image.
I also tried to use the composite_channel function, but did not manage 
to do anything with it.

Does someone has any clue ?
Thanks,
Mickaël.

Re: [wand] composite -blend with wand

From:
Hong Minhee
Date:
2012-12-08 @ 03:05
Thanks for your question, we get aware of a bug of Image.transparentize() 
method — even worse, it hadn’t been tested.

I quickly fixed the bug, and not it works well at least on 0.2-maintenance
branch (3666941c32).  This version isn’t published to PyPI yet, but you 
can install now it using pip:

  $ pip install git+git://github.com/dahlia/wand.git@0.2-maintenance

Although it had a bug, your code still won’t work until you change 
im.save() to background.save().  Image.composite() method is applied to 
its receiver, not its first argument.  (Also, you don’t need to touch 
Image.alpha_channel property.  It’s automatically changed by 
Image.transparentize() if needed.)

The shortest way to do what you want is probably using Image.watermark() method:

  with Image(filename='base.jpg') as base, \
       Image(filaname='input.jpg') as input:
    with base.clone() as output:
      output.watermark(input, 0.3)
      output.save(filename='output.jpg')

The fix will be released to PyPI by being included in 0.2.3 version soon 
(before this year).


Regards,
Hong Minhee


--  
Hong Minhee
Sent with Sparrow (http://www.sparrowmailapp.com/?sig)


On Saturday, December 8, 2012 at 6:17 AM, mickael wrote:

>  
> Hi all,
>  
> I want to do with wand something equivalent to the ImageMagick command
> "composite -blend 30 base.jpg input.jpg output.jpg"
>  
> I tried to do :
> > -background = Image(filename=base.jpg)
> > -im = Image(filename=input.jpg)
> > -im.alpha_channel = True
> > -im.transparentize(0.3)
> > -background.composite(im, 0, 0)
> > -im.save(filename=output.jpg)
> >  
>  
>  
> but the transparentize does not seem to work as expected, and the result  
> is the input.jpg image.
> I also tried to use the composite_channel function, but did not manage  
> to do anything with it.
>  
> Does someone has any clue ?
> Thanks,
> Mickaël.
>  
>  

Re: [wand] composite -blend with wand

From:
mickael
Date:
2012-12-08 @ 20:52
Thanks for your quick answer and bugfix !

I have installed the maintenance branch and it works well for me now.

Regards,
Mickaël.


Le 08/12/2012 04:05, Hong Minhee a écrit :
> Thanks for your question, we get aware of a bug of 
> Image.transparentize() method — even worse, it hadn’t been tested.
>
> I quickly fixed the bug, and not it works well at least on 
> 0.2-maintenance branch (3666941c32).  This version isn’t published to 
> PyPI yet, but you can install now it using pip:
>
>   $ pip install git+git://github.com/dahlia/wand.git@0.2-maintenance
>
> Although it had a bug, your code still won’t work until you change 
> im.save() to background.save().  Image.composite() method is applied 
> to its receiver, not its first argument.  (Also, you don’t need to 
> touch Image.alpha_channel property.  It’s automatically changed by 
> Image.transparentize() if needed.)
>
> The shortest way to do what you want is probably using 
> Image.watermark() method:
>
>   with Image(filename='base.jpg') as base, \
>        Image(filaname='input.jpg') as input:
>     with base.clone() as output:
>       output.watermark(input, 0.3)
>       output.save(filename='output.jpg')
>
> The fix will be released to PyPI by being included in 0.2.3 version 
> soon (before this year).
>
>
> Regards,
> Hong Minhee
>
> -- 
> Hong Minhee
> Sent with Sparrow <http://www.sparrowmailapp.com/?sig>
>
> On Saturday, December 8, 2012 at 6:17 AM, mickael wrote:
>
>>
>> Hi all,
>>
>> I want to do with wand something equivalent to the ImageMagick command
>> "composite -blend 30 base.jpg input.jpg output.jpg"
>>
>> I tried to do :
>>> -background = Image(filename=base.jpg)
>>> -im = Image(filename=input.jpg)
>>> -im.alpha_channel = True
>>> -im.transparentize(0.3)
>>> -background.composite(im, 0, 0)
>>> -im.save(filename=output.jpg)
>>
>> but the transparentize does not seem to work as expected, and the result
>> is the input.jpg image.
>> I also tried to use the composite_channel function, but did not manage
>> to do anything with it.
>>
>> Does someone has any clue ?
>> Thanks,
>> Mickaël.
>