bash - Can I edit an image file from command line?
问题描述
As a school project, I need to automatically edit image files by bringing little changes to them. To be more specific, at this early stage I'd be happy to just apply the Bucket fill option to some areas (the areas and the color would be decided at runtime of the shell script). I wonder if there is a utility or a program that allows to be executed via the command line and to apply the desired changes if written from the shell/in a shell script.
(In case it matters, I can work on either Linux or Windows)
解决方案
In ImageMagick 6, you can flood fill a region with another color as
convert image.suff -fuzz XX% -fill red -draw "color x,y floodfill" -alpha off result.suffix
The above command will fill red color starting at coordinates x,y and stopped when any color in the image nearby exceeds the threshold values XX% from the -fuzz values.
Example:
convert color_test.png -fuzz 0% -fill white -draw 'color 30,20 floodfill' -alpha off color_floodfill.png
See https://imagemagick.org/Usage/draw/#color
If using ImageMagick 7, change convert to magick (and not magick convert)
推荐阅读
- excel - 将表中的一行复制到同一个表的末尾
- nativescript - 数据绑定错误:未定义属性
- c# - 获取附加调试器的名称
- java - 找到第 n 个斐波那契数,其中 n 可以变化到 10^9
- spring - 在 Micronaut + Hibernate 中为 Heroku Postgres 以编程方式设置 DataSource
- python - 如何使用 python 将 ascii 编码的换行符写入文件
- java - 使用 azure junit 测试在 SpringCloud 函数中出错
- javascript - 尝试使用 react 和 Reddit API 显示搜索历史
- python - 越来越长的十六进制哈希
- css - 居中对齐文本机智