[magick-users] Background issue converting .eps to .png
zentara
zentara1 at sbcglobal.net
Wed Oct 22 13:39:36 PDT 2008
On Tue, 21 Oct 2008 12:43:05 -0400
Michael Stroh <stroh at astroh.org> wrote:
>I'm using simple commands like
>
>convert lightcurve.eps lightcurve.png
>
>Are there any additional things I can try to get the .png file to look
>the way I want it to?
Here is a Perl script that does the conversion, and avoids a temp pdf file
by using a blob.
#!/usr/bin/perl
use warnings;
use strict;
use Image::Magick;
# a shell script equivalent... for comparison
#convert -resize 99% -density 160x160 -quality 100% -compress Lossless lightcurve.eps lightcurve1.pdf
#convert -quality 100% -compress Lossless lightcurve1.pdf lightcurve1.png
#convert lightcurve1.png -trim lightcurve2.png
#convert -bordercolor SkyBlue -border 40x40 lightcurve2.png lightcurve3.png
my $img = Image::Magick->new;
$img->Read('lightcurve.eps');
$img->Resize('101%'); #needed hack for portrait/landscape conversion
$img->set('quality'=> 100, );
$img->set('compresion'=> 'LosslessJPEG' );
#$img->Write(filename=>'zzimage.pdf'); #works good when written to temp file
# but using an inline blob here to avoid a temp file
$img->set('magick'=>'pdf');
my $blob = $img->ImageToBlob();
#and the opposite
my $img1 = Image::Magick->new(magick=>'pdf');
$img1->BlobToImage( $blob );
$img1->set('quality'=> 100, );
$img1->set('compresion'=> 'LosslessJPEG' );
#add a border
$img1->Border('bordercolor' => 'SkyBlue','width'=>40,'height'=>40);
$img1->Write(filename=>'zzzimage.jpg');
$img1->Write(filename=>'zzzimage.png');
__END__
zentara
--
I'm not really a human, but I play one on earth.
http://zentara.net/Remember_How_Lucky_You_Are.html
More information about the Magick-users
mailing list