On Fri, 5 Jun 2009 23:32:19 +0100
Lex Thoonen <[email protected]> wrote:
| Hi Magick-users,
| 
| I'd like to create a transparent png with perlmagick from this file:
| 
| http://www.allesoversterrenkunde.nl/fotos/temp/aardebolletje3.png
| 
| using this file as a mask:
| 
| http://www.allesoversterrenkunde.nl/test/images/aardebolletje-mask.png
| 
| so only the earth stays visible.
| 
| I've tried lots but I don't get it to work...
| 
| Any ideas?

That is dead easy!!!

Look at the PerlMagick 'demo' directory that should be installed on
your system and match it up against the command line handling
  http://www.imagemagick.org/Usage/compose/#copyopacity

The trick is to make sure the mask has no ALPHA channel enabled
so IM copies the grayscale into the image, rather than the alpha
channel itself!

=======8<--------CUT HERE----------axes/crowbars permitted---------------
#!/bin/perl
#
# Command Line equivelence
#   convert aardebolletje3.png aardebolletje-mask.png \
#           +matte -compose CopyOpacity -composite \
#           -write show:  earth.png
#
use strict;
use Image::Magick;

my $earth=Image::Magick->new();
$earth->Read("aardebolletje3.png");

my $mask=Image::Magick->new();
$mask->Read("aardebolletje-mask.png");

$mask->Set(alpha=>"Off");

$earth->Composite(
   image=$mask,
   compose='CopyOpacity',
);

$earth->Write('show:');
$earth->Write('earth.png');

=======8<--------CUT HERE----------axes/crowbars permitted---------------



  Anthony Thyssen ( System Programmer )    <[email protected]>
 -----------------------------------------------------------------------------
     Dungeons and Dragons Famous Last Words: 
                      "C'mon DM, let's see some REAL monsters!"
 -----------------------------------------------------------------------------
     Anthony's Home is his Castle     http://www.cit.gu.edu.au/~anthony/
_______________________________________________
Magick-users mailing list
[email protected]
http://studio.imagemagick.org/mailman/listinfo/magick-users

Reply via email to