有没有办法使 ImageMagick 中除圆角矩形之外的图像变暗?

发布于 2025-01-21 02:05:14 字数 397 浏览 1 评论 0原文

展示。

原文:
原始图片

ImageMagick 之后:
编辑后的图像

我有一些想法:

  • 复制图像,裁剪副本,然后将图像拼合在一起
  • 反向蒙版?

有人有什么建议吗?

To demonstrate.

Original:
Original Image

After ImageMagick:
Edited Image

I have some ideas:

  • Duplicate the image, crop the duplicate, then flatten the images together
  • Reverse mask?

Does anyone have any suggestions?

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

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

发布评论

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

评论(2

相思碎 2025-01-28 02:05:14

尽管已成功回答了这一点,但我将使用IMV6提供另一种简单的方法...

convert pasta.jpg -fill white \
   \( +clone -evaluate set 25% -draw "roundrectangle 20,20 80,80 15,15" \) \
   -compose multiply -composite result.png

在输入图像中阅读后,在括号中,它克隆了输入,并使用-Evaluate将整个克隆设置为25 % 灰色的。在您要保存的区域中,在该灰色图像上绘制了白色的“圆形角”。面膜看起来像这样...

​这将白色矩形区域留在原始输入中,其余​​图像乘以0.25,使其变暗。结果...

“在此处输入映像说明”

通过将“转换”转换为“ magick”,此命令应在IMV7中起作用。它应该通过将续线“ \”更改为carets“^”,并在括号前删除任何后斜线,从而在Windows CLI上也有效,因此此“ \(... \)”(.. 。)”。

Although this has been successfully answered, I'll offer another simple approach using IMv6...

convert pasta.jpg -fill white \
   \( +clone -evaluate set 25% -draw "roundrectangle 20,20 80,80 15,15" \) \
   -compose multiply -composite result.png

After reading in the input image, in parentheses it clones the input and uses -evaluate to set the entire clone to 25% gray. A white "roundrectangle" is drawn on that gray image in the area you want to preserve. The mask looks like this...

enter image description here

Then after the parentheses, that mask and the input image are composited with -compose multiply. That leaves the white rectangle area as it was in the original input, and the rest of the image is multiplied by 0.25, leaving it darkened. The result...

enter image description here

This command should work just the same in IMv7 by changing "convert" to "magick". And it should work as well on Windows CLI by changing the continued-line backslashes "\" to carets "^", and removing any backslashes before the parentheses, so this "\(...\)" to this "(...)".

淡写薰衣草的香 2025-01-28 02:05:14

您可以在 Imagemagick 中通过使整个图像变暗、创建圆角矩形蒙版图像来实现此目的,然后使用蒙版图像将原始图像与变暗图像合成。

输入:

在此处输入图像描述

convert pasta.jpg \
\( -clone 0 -brightness-contrast -75,0 \) \
\( -clone 0 -fill white -colorize 100 -fill black -draw "roundrectangle 20,20 80,80 15,15" -alpha off \) \
-compose over -composite \
pasta_rect.jpg

结果:

在此处输入图像描述

You can do that in Imagemagick by darkening the whole image, creating a round rectangle mask image, then composite the original with the darkened using the mask image.

Input:

enter image description here

convert pasta.jpg \
\( -clone 0 -brightness-contrast -75,0 \) \
\( -clone 0 -fill white -colorize 100 -fill black -draw "roundrectangle 20,20 80,80 15,15" -alpha off \) \
-compose over -composite \
pasta_rect.jpg

Result:

enter image description here

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