Search code examples
imagemagickimagemagick-convert

using imagemagic Convert batch operation takes too much time versus Gimp. How to execute per file in batch mode?


Using imagemagic Convert batch operation takes too much time versus Gimp. How to execute per file in batch mode?

The following command can be executed to bacth convert 200+ image files. However, Convert / imagemagic creates tmp files for all images and then apply whatever process you gave to it eg. rotation.

 convert '*.jpg' -set filename:fn '%[basename]' -units PixelsPerInch  -rotate -90  -density 300 -quality 95  -resize 28% '%[filename:fn].jpg'

This means that it may consume a lot of memory / temporary disk size and it takes too much time. Now it is running more than 10+ minutes and not finished yet.

In comparison, GIMP -in batch mode- that makes operations per file (rotate, finish, next, rotate, finish, next etc.), it takes much less time (2-3 minutes).

I think GIMP uses imagemagick convert.

How can I run convert (in batch mode) in linux terminal and make operation PER FILE and not PER ALL FILES?

many files from imagemagicjk convert


Solution

  • By experimenting and looking for other examples,

    i found that this imagemagick command operates per file and not in same time on all files:

     for pic in *.jpg; do convert -units PixelsPerInch  -rotate -90  -density 300 -quality 95  -resize 28% "$pic" "$pic";done
    

    Note: if you dont want to replace original photo, the last "$pic" may be manipulated. eg. "$pic" "${pic//}_copy.jpg"