Imagick::resizeImage 与 Imagick::scaleImage

发布于 2024-10-21 08:00:16 字数 509 浏览 1 评论 0原文

resizeImagescaleImage 之间有什么区别?

如果图像的大小 > 我需要调整图像的大小$myLimit

示例(伪代码):

$myLimit = 1MB
user uplaod an image of 1000x1000 of 2MB
2MB > $myLimit
while( $imagefilesize > $myLimit  ) {
  resizeImageBy 0.9%;
}

//> output 900x900 image of 900 kB

while 块中,我应该使用两种方法中的哪一种?

编辑:我发现了一些可以帮助的东西: http://www.imagemagick.org/Usage/resize/ 但可以有人简化一下吗?

What are the differences between resizeImage and scaleImage?

I need to resize an image if its size is > $myLimit

Example (pseudocode):

$myLimit = 1MB
user uplaod an image of 1000x1000 of 2MB
2MB > $myLimit
while( $imagefilesize > $myLimit  ) {
  resizeImageBy 0.9%;
}

//> output 900x900 image of 900 kB

In the while block, which of the two methods should I use?

Edit: I found something that could help: http://www.imagemagick.org/Usage/resize/ But could someone simplify that?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

百思不得你姐 2024-10-28 08:00:16

两者之间的区别似乎是 scaleImage 进行原始的、基于像素的调整大小,而 resizeImage 可以使用插值过滤器

imagick::INTERPOLATE_AVERAGE
imagick::INTERPOLATE_BICUBIC
imagick::INTERPOLATE_BILINEAR
...

可能会产生更好的结果。

有关各种插值方法的更多信息,请访问 Wikipedia

The difference between the two seems to be that scaleImage does a raw, pixel based resize, while resizeImage can use an interpolation filter:

imagick::INTERPOLATE_AVERAGE
imagick::INTERPOLATE_BICUBIC
imagick::INTERPOLATE_BILINEAR
...

that is likely to produce better results.

More on the various interpolation methods on Wikipedia.

天冷不及心凉 2024-10-28 08:00:16

太棒了,他们自己的文档很糟糕...但是好吧:在我看来 resizeImage 更强大,因此是更好的选择... 此链接显示了不同过滤器的用法以及一些测量值。

Brilliant, their own documentation is awful... But ok: It looks to me like resizeImage is more powerful, and therefore the better choice... This link shows the usage along with some measurements for different filters.

岁月蹉跎了容颜 2024-10-28 08:00:16

根据我的发现,当你想缩小图像时,请使用 resizeImage。因为它可以让您控制图像质量和要使用的滤镜类型。但在同样的情况下,scaleImage也是一个不错的选择,因为当您必须将图像缩小到10倍并且您正在使用resizeImage时,您生成的图像将有许多图形错误。

在第二种情况下,当您必须放大图像时,resizeImage 肯定会出现图形错误,例如标记、线条和其他内容。在这种情况下,scaleImage 就会来救援。

According to my finding, when you want to scale down an image, use resizeImage. Because It gives you control over image quality and type of filter you want to use. But in the same case, scaleImage is also a good choice because when you have to scale down an image to let's say by factor of 10 and you are using resizeImage, then your resulting image will have many graphical errors.

In second case, when you have to scale up and image, then resizeImage will definetely have graphical error like while marks and lines and other stuff. In that case, scaleImage will come to rescue.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文