缩放缩放和向上时,转换不节省大小

发布于 2025-02-05 19:10:12 字数 177 浏览 1 评论 0原文

为了使模糊更快地施加模糊,我首先将图像缩放为缩小图像,然后将其扩展为缩小:

convert - -scale 10% -blur 0x2.5 -resize 1000% RGB:-

这大部分时间都可以使用,但有时输出分辨率与原始输入略有不同。有没有办法迫使管道具有尺寸的尺寸?

In order to make applying blur faster I'm first scaling my image down and then scale it back up:

convert - -scale 10% -blur 0x2.5 -resize 1000% RGB:-

This works most of the time but sometimes the output resolution is slightly different from the original input. Is there a way to force the pipeline to be size-preserving?

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

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

发布评论

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

评论(2

执着的年纪 2025-02-12 19:10:12

您应该能够通过%G

convert input.jpg -scale 10% -blur 0x2.5 -resize '%G!' RGB:-

如果您使用的是 Windows ,则可能需要“%g!”以双引号而不是单引号。

如果使用V7 ImageMagick ,请用magick替换convert


我认为您会遇到错误,因为如果您服用72个像素的10%(例如),您将获得大量像素,即7个像素,然后当您缩放10倍10倍时,您将获得70而不是您的最初72。

You should be able to access the original geometry of the image via %G, so you can do:

convert input.jpg -scale 10% -blur 0x2.5 -resize '%G!' RGB:-

If you are using Windows, you probably want "%G!" in double rather than single quotes.

If you are using v7 ImageMagick, replace convert with magick.


I think you are getting errors because if you take 10% of 72 pixels (say), you will get a whole number of pixels, i.e. 7 pixels and then when you scale back up by a factor of 10 you'll get 70 rather than your initial 72.

谜兔 2025-02-12 19:10:12

如果使用ImageMagick 7,则可以执行以下操作:

magick input.jpg -set option:wd "%w" -set option:ht "%h" -scale "%[fx:wd/10]x%[fx:ht/10]" -blur 0x2.5 -resize "%[fx:wd]x%[fx:ht]\!" RGB:-

这存储输入宽度和高度。然后,使用存储的值将这些维度的1/10缩放,然后进行模糊,然后将其精确地调整回原点输入大小。注意!这迫使调整大小到确切的尺寸。

或更简单,而无需存储输入宽度和高度:

magick lena.jpg -scale "%[fx:w/10]x%[fx:h/10]" -blur 0x2.5 -resize "%[fx:w]x%[fx:h]\!" lena_x.jpg

If you are using Imagemagick 7, you can do the following:

magick input.jpg -set option:wd "%w" -set option:ht "%h" -scale "%[fx:wd/10]x%[fx:ht/10]" -blur 0x2.5 -resize "%[fx:wd]x%[fx:ht]\!" RGB:-

This stores the input width and height. Then uses the stored values to scale by 1/10 of those dimensions, then does the blur, then resizes exactly back to the origin input size. Note the ! that forces the resize to the exact dimensions.

or simpler without storing the input width and height:

magick lena.jpg -scale "%[fx:w/10]x%[fx:h/10]" -blur 0x2.5 -resize "%[fx:w]x%[fx:h]\!" lena_x.jpg
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文