### 5) IMAGES: RESIZING WITH IMAGE MAGICK CLI: #### Resize and compress by 85% and autonumeral (%02d -> two digits) `magick *.jpg -resize 1440 -quality 85 ./resized/AH_000003-%02d.jpg` #### Rotate 90 degrees if height > width `convert input.jpg -rotate 90< output.jpg` #### Save the output file with the same filename as original (after rotating the image on this example) `-set filename:f` --> key we want to set `'%t'` --> value we assign to the previous key. %t is a shortcut to retrieve the filename. The long form is `%[basename]` `magick planos/*.jpg -rotate '-90<' -set filename:f '%t' planos/'%[filename:f].png'` #### Save the output file containing the directory name on its filename. The input file must contain the direcoty on its path, so you must be one level up... ``` $~/Desktop > magick AH_000007/*.jpg -resize 1440 -quality 85 -set filename:myname '%d' AH_000007/resized/'%[filename:myname]-%02d.jpg' ``` The output file names will be something like: `AH_000007-01.jpg` `AH_000007-02.jpg` `AH_000007-....jpg` #### Resize and output to a different folder with same file names `mogrify -resize 1440 -quality 85 -path ./resized *.jpg` #### Output filename autonumber starting from a specific value. Using the -scene [number] flag, where [number] is the number where the automatic count starts from. On the following example, will output files autonumber starting from 5 (05,06,07...) `magick AH_000032/*.jpg -resize 1440 -quality 85 -scene 5 -set filename:myname '%d' AH_000032/resized/'%[filename:myname]-%02d.jpg'` ### Convert images to pdf `convert *.png -quality 100 document.pdf` ### Batch convert to webp to different output directory `mogrify -format webp -quality 80 -resize 1940 -path ./resized *.JPG`