有没有办法使 ImageMagick 中除圆角矩形之外的图像变暗?
To demonstrate.
I have some ideas:
- Duplicate the image, crop the duplicate, then flatten the images together
- Reverse mask?
Does anyone have any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尽管已成功回答了这一点,但我将使用IMV6提供另一种简单的方法...
在输入图像中阅读后,在括号中,它克隆了输入,并使用
-Evaluate
将整个克隆设置为25 % 灰色的。在您要保存的区域中,在该灰色图像上绘制了白色的“圆形角”。面膜看起来像这样...这将白色矩形区域留在原始输入中,其余图像乘以0.25,使其变暗。结果...
通过将“转换”转换为“ magick”,此命令应在IMV7中起作用。它应该通过将续线“ \”更改为carets“^”,并在括号前删除任何后斜线,从而在Windows CLI上也有效,因此此“ \(... \)”(.. 。)”。
Although this has been successfully answered, I'll offer another simple approach using IMv6...
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...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...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 "(...)".
您可以在 Imagemagick 中通过使整个图像变暗、创建圆角矩形蒙版图像来实现此目的,然后使用蒙版图像将原始图像与变暗图像合成。
输入:
结果:
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:
Result: