[magick-developers] How to use "Set(extract=>geometry)" . . .

ademmler news at ademmler.com
Fri Jun 29 01:53:02 PDT 2007


Hi IM Gurus!

I am trying to extract a area from a given PDF file.
I thought of using some thing like "$image->Set(extract=>100x100+10 
+10)".
But I always get the whole image. Help would be nice!

Thanks Alex

Here is my code:
#!/usr/perl -w

use strict;
use Image::Magick;

my $infile = shift;
my $out = $infile;
$out =~ s/.pdf$|.gs$/.tif/i;
	

## read image
my $image = Image::Magick->new;
$image->Set(depth=>8);
$image->Set(colorspace=>'CMYK');
$image->Set(depth=>8);
$image->Set(density=>'150');
$image->Set(extract=>'100x100+10+10');

my $readimage = $image->Read($infile);
	die "Can't read Image: $readimage\n" if "$readimage";

## get image infos
print "Get Image Infos:\n";	

my @info = $image->GetAttribute(colorspace =>'True', verbose=>'True');
print"@info\n";

my ($width, $height) = $image->Get('width','height');
print"Dimension: $width x $height\n";

my $bbox =$image->Get('bounding-box');
print "BoundingBox: $bbox\n";

my $colors = $image->Get('colors');
print"Colors: $colors\n";

my ($xres, $yres) = $image->Get('x-resolution','y-resolution');
print"Resolution: $xres x $yres\n";



## write image and open it
my $write = $image->Write(filename=>"$out", compression=>'none');
	die "Cant  write outfile $out ($!)\n" if "$write";
	
system("open $out");

exit 0;




More information about the Magick-developers mailing list