简体   繁体   English

如何使用imagemagick调整图像大小?

[英]How to resize image using imagemagick?

When I resize image using imagemagick then it shown like cropped. 当我使用imagemagick调整图像大小时,它显示为裁剪。 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 在调整图像大小之前,请参见下图 在此输入图像描述
See the below image after image resize it shown below 图像调整大小后,请参见下图,如下所示

在此输入图像描述

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? 我该怎么办?

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 . 上面的参数与ImageMagick交谈:“请从我的图像中心提取大小为100x100的区域。有关详细信息,您可以阅读命令行选项文档

So, sulution is following args: 因此,关注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. 我没有使用.net的图像magick包装器,因为它是32位(至少半年前)并且它导致不同的问题。

In general in web applications usual need only two operations: 通常在Web应用程序中通常只需要两个操作:
1.Resize 1.Resize
2.Crop 2.Crop
Above commands use only one exe file: convert.exe . 上面的命令只使用一个exe文件: convert.exe

So i've done small wrapper thats run convert.exe with arguments. 所以我做了一个小包装器,它运行带有参数的convert.exe。

MB a little later i post here github url to wrapper project if someone interest in it. MB稍后我在这里发布github url到包装项目,如果有人对它感兴趣的话。

Please, Use the answer of this question and you get what you want!!! 请使用这个问题的答案,你得到你想要的!

How to compress jpg image? 如何压缩jpg图像?

You could use something like this : 你可以使用这样的东西:

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

This will resize image in aspect ration. 这将在宽高比中调整图像大小。

To create image of exact dimension 200x200, you could use 要创建精确尺寸200x200的图像,您可以使用

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM