Hello all. I am working with a large quantity of images that I need to
perform a number of operations on. Mainly resizing and cropping. I am
finding that 100% of the images crop perfectly (I work for a newspaper and
the crops come from how publishing system) but on 75-80% of the images
resize correctly.  As an example I have an image that is 150dpi and sized at
5467x7506. I need to take this image to no more than 250 pixels wide.. If I
do this in photoshop, it works perfectly. With ImageMagick/Perl the image
does resize but to 2624x3603.

I am only giving widths (to fit in a colum dimension) for these images since
the height can be whatever works and keeps the image proportions.

Here is the code I am using... again, this code works on about 80% of the
200 or so images I process. Any thoughts or ideas would be most welcome.

Scott Seller
USA TODAY

sub image_resize
{
  $picture_to_process = $_[0];

  my $image = Image::Magick->new;
  my $x     = $image->Read($picture_to_process);

  $width     = $image->Get('width');
  $height    = $image->Get('height');


  #first determine what size the image needs to be
  if ($width > $height)
    {
      print LOG_FILE &now, "Image H/W: $height/$width. This is a horizontal
image\n";
      if ($width > 937)
        {
          $image->Resize( '432' );
          print LOG_FILE &now, "resize the image to 432 pixels wide\n";
        }
      else
        {
          #resize to 455 pixels wide
        }
    }
  else
    {
      print LOG_FILE &now, "Image H/W: $height/$width. This is a verticle
image\n";
      if ($width > 937)
        {
          #resize the image to 937 pixels wide
        }
      else
        {
          $image->Resize( '250' );
          print LOG_FILE &now, "resize to 250 pixels wide\n";
        }

    }



  my $result = $image->Write($picture_to_process);
  my $result = $image->Write($picture_to_process."_resize.jpg");

  undef $image;    # destroy object to prevent memory issues

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

Reply via email to