Imagick::resizeImage 与 Imagick::scaleImage
resizeImage
和 scaleImage
之间有什么区别?
如果图像的大小 > 我需要调整图像的大小$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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
两者之间的区别似乎是
scaleImage
进行原始的、基于像素的调整大小,而resizeImage
可以使用插值过滤器:可能会产生更好的结果。
有关各种插值方法的更多信息,请访问 Wikipedia。
The difference between the two seems to be that
scaleImage
does a raw, pixel based resize, whileresizeImage
can use an interpolation filter:that is likely to produce better results.
More on the various interpolation methods on Wikipedia.
太棒了,他们自己的文档很糟糕...但是好吧:在我看来 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.
根据我的发现,当你想缩小图像时,请使用 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.