.netimagemagickmagicknet

detect picture orientation with ImageMagick


I want to resize a picture to a new size using one parameter: Width.

If the picture is horizontal, the new size will be: width = Width, height = proportional to width.

And if the picture is vertical, the new size will be: height = Width, width = proportional to height.

Any idea how to implement this?

I'm using ImageMagick with MagickNet wrapper.


Solution

  • From the usage reference at http://www.imagemagick.org/Usage/resize/

    convert org.jpg    -resize widthxwidth  final.jpg
    

    e.g. widthxwidth can be 256x256

    The aspect ratio will be kept and the resizing will be done within the boundary of 256 X 256 pixel square.

    Quoted from the page above:

    Resize will fit the image into the requested size. It does NOT fill, the requested box size.