How to resize image using imagemagick?

When I resize an image using imagemagick, it is displayed as cropped. I use below code to 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 image below before resizing the image. enter image description here
See image below after resizing image below

enter image description here

I definitely want the resizable image to display as a full image, as shown before resizing. in my output image it looks like cropped the full view of the input image is not shown.
How can i do this?

+4
source share
4 answers

I assume this is because you are using the following parameters:

 -gravity center -extent 100x100 

Above the parameters, talk to ImageMagick: β€œPlease extract a 100x100-sized area from the center of my image. For more information, you can read the documentation on the command line .

So, sulution is the following arguments:

 image_Input.jpg -resize 100x100 image_Output.jpg 

From my practice:

I do not use the image magic chip for .net because it was 32 bits (at least six months ago) and this causes different problems.

Typically, web applications typically require only two operations:
1 solution
2.Crop
The above commands use only one exe file: convert.exe .

So, I made a small shell that runs convert.exe with arguments.

MB a bit later I write a github url here for a shell project if anyone is interested in this.

+2
source

Please use the answer to this question and you will get what you want!

How to compress jpg image?

+1
source

You can use something like this:

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

This will resize the image in aspect.

To create an image of exact size 200x200, you can use

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

0
source

Source: https://habr.com/ru/post/1346518/


All Articles