0

I am using ImageMagick with PHP to resize images (using its commandline tool "convert").

I am able to resize images and everything works.

What I want to do is I want to resize an image (of any dimension) to an image setting the minimum width and maximum height and at the same time preserve the image resolution/aspect ratio. How do I do this?

Why I want this: I am putting these images in a news feed in my website where I require images to be of width:100% but the problem is height becomes too large for certain images and occupies an entire page. I want to avoid it.

This is what I am using for resize:

$cmd="convert -thumbnail ".$width."x".$height." \"".$source."\" \"".$dest."\";";
Vignesh T.V.
  • 1,790
  • 3
  • 27
  • 48
  • If you're already using PHP, why are you doing raw command lines? There's an API for Imagick in PHP. http://stackoverflow.com/questions/18805497/php-resize-image-on-upload/40324941#40324941 – HoldOffHunger Oct 31 '16 at 00:10

1 Answers1

0

You can find the resize options on the Imagemagick website: http://www.imagemagick.org/script/command-line-processing.php#geometry

I do not think these will achieve what you want so I would check the dimensions of your image and calculate the height to go with your width which you can use in your convert code.

Bonzo
  • 5,169
  • 1
  • 19
  • 27