Batch resize images into new folder using ImageMagick

后端 未结 6 2064
余生分开走
余生分开走 2021-01-31 08:37

I have a folder of images over 4MB - let\'s call this folder dsc_big/. I\'d like to use convert -define jpeg:extent=2MB to convert them to

6条回答
  •  余生分开走
    2021-01-31 09:03

    I found that cd-ing into the desired folder, and then using the bash global variable $PWD made my convert not throw any errors. I'm utilizing ImageMagick's recently implemented caption: http://www.imagemagick.org/Usage/text/#caption function to label my images with the base filename and place them in another directory within the first.

    cd ~/person/photos
    mkdir labeled
    for f in $PWD/*.JPG; do
        width=$(identify -format %w $f)
        filename=$(basename $f .JPG)
    convert -background '#0008' -colorspace transparent -fill white -gravity center -size ${width}x100  caption:"${filename}" ${f} +swap -gravity south -composite "$PWD/labeled/${filename}.jpg";
    done
    

提交回复
热议问题