Difference between revisions of "Imagemagick Batch Processing"

From Tomelec
Jump to: navigation, search
(Created page with "[http://www.imagemagick.org Imagemagick] provides powerful tools for image manipulation. These can be easily automated in small shell scripts or command lines. =Shellscript batc...")
 
(Shellscript batch processing)
Line 4: Line 4:
  
 
==Scale a bunch of photos==
 
==Scale a bunch of photos==
This scales all .JPG files in the directory ../mypics to 2048x1536 pixels. Note that the file extension (.JPG) is case sensitive and will not match .jpg files.
+
This scales all .JPG files in the directory ../mypics to 2048x1536 pixels. Note that the file extension (.JPG) is case sensitive and will not match .jpg files. The aspect ratio is preserved.
  <nowiki>for file in ../mypics/*.JPG; do echo $file; convert "$file" -scale 2048x1536 -quality 85 `basename "$file"`; done
+
  <nowiki>for file in ../mypics/*.JPG; do echo $file; convert "$file" -scale 2048x1536 -quality 85 `basename "$file"`; done</nowiki>
</nowiki>
+
 
 +
 
 +
==Crop out a section of PNG files==
 +
This cuts out the upper left 6x17 pixels. '''+0+0''' adjusts the offset
 +
<nowiki>for file in ../my_pngs/*.png; do echo $file; convert $file -crop 6x17+0+0! -depth 8 `basename $file`; done

Revision as of 10:32, 2 September 2013

Imagemagick provides powerful tools for image manipulation. These can be easily automated in small shell scripts or command lines.

Shellscript batch processing

Scale a bunch of photos

This scales all .JPG files in the directory ../mypics to 2048x1536 pixels. Note that the file extension (.JPG) is case sensitive and will not match .jpg files. The aspect ratio is preserved.

for file in ../mypics/*.JPG; do echo $file; convert "$file" -scale 2048x1536 -quality 85 `basename "$file"`; done


Crop out a section of PNG files

This cuts out the upper left 6x17 pixels. +0+0 adjusts the offset

<nowiki>for file in ../my_pngs/*.png; do echo $file; convert $file -crop 6x17+0+0! -depth 8 `basename $file`; done