fmw42 wrote: ↑2013-05-17T18:24:45-07:00
Sorry I missed something in your command. The input images must come first. You were using mogrify syntax with convert and that will not work. I have fixed that error and improved it to skip directories when looking for files (as long as the file has period in it). The following works fine for me. I am putting the rose mage in the center of a bunch of logo images in several directories:
Code: Select all
cd
list=`find /Users/fred/images/test -type d`
for directory in $list; do
echo "directory=$directory"
cd $directory
imglist=`ls | grep "\."`
for file in $imglist; do
echo "file=$file"
filename=`convert $file -format "%t" info:`
convert $file -draw "gravity center image src-over 0,0 70,46 '/Users/fred/images/test/rose.png'" ${filename}_new.jpg
done
cd
done
Note the syntax in the line (and I swapped the order of your single and double quotes)
convert
$file -draw "gravity center image src-over 0,0 70,46 '/Users/fred/images/test/rose.png'"
${filename}_new.jpg
Results
Code: Select all
directory=/Users/fred/images/test
file=rose.png
file=rose_new.jpg
file=rose_new_new.jpg
file=rose_new_new_new.jpg
directory=/Users/fred/images/test/test1
file=logo.jpg
file=logo1.jpg
file=logo2.jpg
directory=/Users/fred/images/test/test1/test3
file=logo.jpg
file=logo1.jpg
file=logo2.jpg
directory=/Users/fred/images/test/test2
file=logo.jpg
file=logo1.jpg
file=logo2.jpg
this command works well, thanks
I have three more question, pls help
①can it use composite? such as "composite -gravity southeast -geometry +10+0 -dissolve 100" these kind of command
②can it overwrite original file, do not create new file?
③if file name contain special characters(I use centos vm, and use it to process windows file) such as 1 (8).jpg, it show error like:
file=(8).jpg
convert: unable to open image `(8).jpg': No such file or directory @ error/blob.c/OpenBlob/2709.
convert: no images defined `info:' @ error/convert.c/ConvertImageCommand/3210.
convert: unable to open image `(8).jpg': No such file or directory @ error/blob.c/OpenBlob/2709.
convert: no images defined `_new.jpg' @ error/convert.c/ConvertImageCommand/3210.
how the write the batch command, thanks~