How to batch resize images in Ubuntu recursively within the terminal?

前端 未结 6 1362
栀梦
栀梦 2020-12-23 10:15

I have multiple images stored in a set of organized folders. I need to re-size those images to a specific percentage recursively from their parent directory

6条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-23 10:29

    You can use imagemagick tool for batch resize.

    It will maintain the aspect ratio

    $ convert dragon.gif    -resize 64x64  resize_dragon.gif
    

    It will not maintain the aspect ratio

    $ convert dragon.gif    -resize 64x64\!  exact_dragon.gif
    
    $ cat resize.sh 
    #!/bin/bash
    for f in `find . -name "*.jpg"`
    do
        convert $f -resize 45x60\!  $f.resize.jpg
    done
    

    It will resize the image to 45x60 without maintaining the aspect ratio in current directory.

提交回复
热议问题