ImageMagick: Watermark image and keep file name

大憨熊 提交于 2019-12-24 13:55:05

问题


I have this code but I would like to edit it so the exported file name is the same as the file name used to make it

mogrify -composite -gravity center ~/Desktop/civmap-client-master/data/watermark.png ~/Desktop/civmap-client-master/data/nowm/*.png ~/Desktop/civmap-client-master/data/wm/*.png

It just throws an error when I used *.png as my exported file name. Please note I have multiple files in the /nowm/ directory. I am using a Mac.

Thanks alot :)


回答1:


The mogrify command does not accept -composite as an operation as it takes just 2 images. You will have to use a loop:

cd ~/Desktop/where/the/input/images/are
for f in *.png; do 
  echo $f
  convert -gravity center "$f" "~/Desktop/path/to/watermark.png" -composite "~/Desktop/path/to/output/$f"
done


来源:https://stackoverflow.com/questions/31898078/imagemagick-watermark-image-and-keep-file-name

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!