Search code examples
bashgraphicsmagickgnu-parallel

Cannot run graphicsmagick parallel


I want to run a resize job in parallel with gnu paralllel:

ls *.*  | parallel gm convert -gamma 0.454545 -strip -filter Lanczos -resize 1280x1280> -gamma 2.2 -format png \"{}\" \"./out/{.}-huge.png\"

It gives an error:

gm convert: Unable to open file (2.2) [No such file or directory].

So how do I escape ">" properly?


Solution

  • Something like this:

    parallel gm convert -gamma 0.454545 -strip -filter Lanczos -resize '1280x1280\>' -gamma 2.2 -format png {} ./out/{.}-huge.png ::: *
    

    Or:

    ls | parallel gm convert -gamma 0.454545 -strip -filter Lanczos -resize '1280x1280\>' -gamma 2.2 -format png {} ./out/{.}-huge.png
    

    (Apart from filenames containing \n it is actually safe to pass ls to GNU Parallel: It will do the quoting of special chars).