在 image magick 中更改图像的背景

发布于 2024-12-12 20:05:29 字数 231 浏览 2 评论 0原文

我正在使用 imagemagick 这个命令将图像和背景的大小扩展为白色。

convert input.png -extent 495X320 -gravity center  -background white output.jpg

大小正在执行范围,但背景每次都是黑色的。我尝试了很多方法,但每次都是同样的黑色。所以有人可以帮助我如何解决这个问题。任何帮助和建议都将非常感激。

I am using this command for imagemagick to extend the size of an image and background to white

convert input.png -extent 495X320 -gravity center  -background white output.jpg

The size is doing extent but the background is black every time. I tried many methods but the same black is coming every time.So can some one help me how to solve this. Any help and suggestions will be highly appreciable.

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

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

发布评论

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

评论(2

私野 2024-12-19 20:05:29

这里的顺序很重要,在 -extent 之前使用 -background

convert input.png -background white -extent 495X320 -gravity center output.jpg

The order is important here, use -background before -extent:

convert input.png -background white -extent 495X320 -gravity center output.jpg
淡写薰衣草的香 2024-12-19 20:05:29

把这个留给那些尝试过其他答案但仍然不起作用的人。

就我而言,我需要

convert image.png -resize 80% -quality 80% -background white image-edited.jpg

在末尾添加 -flatten 选项,它应该可以工作。所以就像:

convert image.jpg -resize 80% -quality 80% -background white -flatten image-edited.jpg

Leaving this for people that have tried the other answer but it still does not work.

In my case I needed

convert image.png -resize 80% -quality 80% -background white image-edited.jpg

Add the -flatten option at the end and it should work. So like:

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