Sizing Problems

MagickWand for PHP is an object-oriented PHP interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning MagickWand for PHP.
Post Reply
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Sizing Problems

Post by anthony »

A couple of things....
  • Use -resize instead of -geometry
  • Also -strip (or use -thumbnail resizing) to remove profiles.
  • Read in images BEFORE resizing them.
Also
  • You don't need to check width and height of images for the resize, you can have IM resize images to fit a box, and never enlarge. By default IM will preserve the image aspect ratio.
For example the whole function ResizeImageUsingIM contents can be replaced with

Code: Select all

   Exec("$config[convert] \"$image\" -thumbnail \"$size"."x"."$size>\" -quality \"$config[imagequality]\" \"$newimage\" ");
  return file_exists($newimage);
without the need for the identify, or all the calculations as IM does that for you!

PS; your "desc:" comment after this function also need updating!!! It is missleading to say that the function 'resizes image' when it is 'reading' or 'writing' images.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply