I create PNG
image files with GIMP
and want to make several icons from that PNG
image of different, size and file names.
I wish to 'batch' convert with ImageMagick
or something similar. And have the naming convention and size requirements read from a text file possibly because I also want to create another separate image using GIMP
and have that re-sized multiple times with different file names on each also.
Edit
One image file needs to get converted into THIS:
Icon.png
Icon@2x.png
Icon-72.png
Icon-72@2x.png
the file dimensions to be THIS:
57x57
114x114
72x72
144x144
$ convert image.png -resize 57x57 Icon.png
$ convert image.png -resize 114x114 Icon@2x.png
# ...etc
so if there's a text file storing the map "file name -> picture size" just in two columns, then you should be able to iterate through lines eg like this:
cat map.txt | while read line; do
file=$(echo $line | awk '{print $1}')
size=$(echo $line | awk '{print $2}')
newfile=${file%.png}-new.png
convert $file -resize $size $newfile
done
It's kind of hard to guess what you mean, but suppose params.txt
looks like this:
-resize 64x64
Then you could do this:
#!/bin/bash
params=$(cat params.txt)
for f in *.png
do
newname=${f%.png}_new.png
echo convert "$f" $params "${newname}"
done
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.