This may help at least indirectly...
 
I work as a client on several shared servers where I do not have  direct 
control of or access to root and thus no direct control over  versions of 
ImageMagick and PerlMagick installed.  I have yet to find a  documentation 
history of 
changes in PerlMagick command syntax that  correspond with the various 
ImageMagick versions.  Does anyone know of  their existence?
 
Anyway, to minimize exposure to changes that have or can occur among  
versions I've learned to do whatever I can (mathematically) in Perl and  only 
leave 
to ImageMagick via the PerlMagick interface that which  remains.  I use the 
Image::Size module to determine current width  and height.  For proportional 
resizing I calculate the new dimensions  rather than having ImageMagick do it 
so I 
may use a less complex PerlMagick  resize command syntax and hopefully one 
less likely to change over time:

$e = $image->Resize(width=>$newwidth,  height=>$newheight,filter=>"Lanczos");
if ($e) { warn $e; }

For cropping I do everything I can first mathematically so I need only  
provide an already determined geometry to get the job done:
 
$geometry = $cwidth . 'x' . $cheight . '+' . $x . '+' . $y;
 
$e = $image->Crop(geometry=>$geometry);
if ($e) { warn $e;  }
$e = $image->Set(page=>'0x0+0+0'); # NEED THIS AFTER EVERY  CROP!!!!!
if ($e) { warn $e; }
 
The set page command is required because the crop command with a fully  
qualified geometry does not (may not depending on version?) also effect the  
image 
"canvas".  Learning that was a chore and a perfect example of  difficulties 
encountered as a result of less than thorough PerlMagick  documentation (at 
least that I can find).
 
Another suggestion (more as a question) is would it not be possible to use  
Perl's "system" command to shell out to ImageMagick directly and thus take  
advantage of the much better documented command line interface?
 
Rob
 
 
In a message dated 1/25/2008 4:36:10 A.M. Central Standard Time,  
[EMAIL PROTECTED] writes:

Here's  what I came up with so far, which works fairly well with the 
mention that  in perlmagick "gravity" and "repage" are either not 
implemented at all or  broken? This is really annoying as for smaller 
thumbnails I needed to get  a slice from the middle of the image, and 
then a thinner slice from the  bottom of that.

use Image::Magick;
use File::Glob qw(:glob  :nocase);

$fpat = shift or die "no files\n";
@flist=  bsd_glob($fpat);
mkdir("resized");
foreach $name (@flist)
{
$image =Image::Magick -> new();
$result=$image->Read($name);
die $result if  $result;
my($x, $y)=$image -> Get('width',  'height');
if($x>$y)
{    
$new_image1    = $image ->  Clone();
if($x/$y<1.61)
{$new_image1 -> Scale(width=>466,  geometry=>"466x");}
else
{$new_image1 -> Scale(height=>288,  geometry=>"x288");}
$new_image1 ->  Crop(width=>466, height=>288, gravity=>center);
#$new_image1->Set( page=>'0x0+0+0' );
$result = $new_image1 -> Write("resized/".$name);
die $result if $result;
$new_image2    = $new_image1 -> Clone();
if($x/$y<3.11)
{$new_image2 -> Scale(width=>165, geometry=>"165x",  
gravity=>South);}
else
{$new_image2 -> Scale(height=>53,  geometry=>"x53", 
gravity=>South);}
#$new_image2->Set( page=>'0x0+0+0' );
$new_image2 -> Crop(geometry=>"165x53+0+0", gravity=>South);   
($new_name = $name)     =~ s/\.jpg/_thumbnail\.jpg/i;
$result =  $new_image2 -> Write("resized/".$new_name);
die $result if $result;
}
}

> -------- Original  Message  --------
> Subject: [magick-users] pass minimum width and  height to resize?
> From: Fred Weinhaus <[EMAIL PROTECTED]>
>  To: [email protected]
> Date: Thu Jan 24 2008 20:07:12  GMT+0200 (EET)
>
>
>
> Hello,
>
> I just  recently created a bash shell script to do this. It is called 
>  squareup. You can find it at 
>  http://www.fmwconcepts.com/imagemagick/index.html
>
> You might be  able to look at what I have done and convert it to 
> perlmagick, if you  are unable to use it as a bash Unix script.
>
> Fred  Weinhaus
>
>
>
>>
>>  Hi  all,
>> The docs state that wxh specified in the command line to  mogrify or
>> through the api are maximum, so an image will fit into,  not fill a
>> rectangle with a different aspect ratio. I would like  to resize to a
>> minimum x or y, center then crop the other  dimension, filling the space
>> available, is this possible? (I'm  using perlmagick)
> 





**************Biggest Grammy Award surprises of all time on AOL Music.     
(http://music.aol.com/grammys/pictures/never-won-a-grammy?NCID=aolcmp003000000025
48)
_______________________________________________
Magick-users mailing list
[email protected]
http://studio.imagemagick.org/mailman/listinfo/magick-users

Reply via email to