Abhishek B.
Abhishek B.

Reputation: 5202

How to resize image using imagemagick?

When I resize image using imagemagick then it shown like cropped. I using below code for resize image

ImageMagickObject.MagickImage imgLarge = new ImageMagickObject.MagickImage();
 object[] o = new object[] { "image_Input.jpg", "-resize", size, "-gravity", "center", "-colorspace", "RGB", "-extent", "100x100", "image_Output.jpg" };
imgLarge.Convert(ref o);

See the below image before image resize enter image description here
See the below image after image resize it shown below

enter image description here

I exactly want that resize image shown full image as shown before re-sized. in my output image it goes to like cropped not shown full view of the input image..
How I can do?

Upvotes: 4

Views: 5712

Answers (2)

Sandeep Pal
Sandeep Pal

Reputation: 2175

You could use something like this :

1) convert youractualimage.png -resize 200x200 newimage.png

This will resize image in aspect ration.

To create image of exact dimension 200x200, you could use

2) convert youractualimage.png -resize 200x200! newimage.png

Upvotes: 0

Andrew Orsich
Andrew Orsich

Reputation: 53675

I guess this is becuase you use following parameters:

-gravity center -extent 100x100

Above params talk to ImageMagick: "Extract, please, area with size 100x100 from center of my image. For more details you can read command line options documentation.

So, sulution is following args:

image_Input.jpg -resize 100x100 image_Output.jpg

From my practice:

I am not using image magick wrapper for .net, because it was 32 bit (at least a half of year ago) and it cause different problems.

In general in web applications usual need only two operations:
1.Resize
2.Crop
Above commands use only one exe file: convert.exe.

So i've done small wrapper thats run convert.exe with arguments.

MB a little later i post here github url to wrapper project if someone interest in it.

Upvotes: 2

Related Questions