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)
_______________________________________________
Magick-users mailing list
[email protected]
http://studio.imagemagick.org/mailman/listinfo/magick-users

_______________________________________________
Magick-users mailing list
[email protected]
http://studio.imagemagick.org/mailman/listinfo/magick-users

Reply via email to