开发者

ImageMagick Convert Loop Hangs

开发者 https://www.devze.com 2023-02-24 17:47 出处:网络
I am running a script 开发者_运维问答intended to resize all images in a folder and its subdirectories if the dimensions are of a certain size. The script hangs on the \"convert\" line after getting th

I am running a script 开发者_运维问答intended to resize all images in a folder and its subdirectories if the dimensions are of a certain size. The script hangs on the "convert" line after getting through about 1,000-2,000 images. (The exact image it hangs on is different every time).

#! /bin/bash

for f in $(find . -wholename "./raw/*.jpg"); do
    # fwidth, fheight, outputdir, filename variables defined...

    if [ "$fwidth" -gt 1000 ] || [ "$fheight" -gt 1000 ]; then
        convert -resize 60% -quality 92 -unsharp 0x0.5 $f ${outputdir}/${filename};
    else
        cp $f ${outputdir}/${filename};
    fi
done


First of describe in more detail what "hanging" means. Does it stop execution? Does convert work at 100% CPU usage for some time? Something else?

Then start debugging the script. Please add some debugging output and try to run the script with bash -x script.sh which should output all commands actually ran.

#! /bin/bash

for f in $(find . -wholename "./raw/*.jpg"); do
    echo "=========== processing file $f"
    # fwidth, fheight, outputdir, filename variables defined...

    if [ "$fwidth" -gt 1000 ] || [ "$fheight" -gt 1000 ]; then
        convert -verbose -resize 60% -quality 92 -unsharp 0x0.5 $f ${outputdir}/${filename};
    else
        cp -v $f ${outputdir}/${filename};
    fi
done
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号