Automatic resizing for 'non-retina' image versions

前端 未结 9 1525
生来不讨喜
生来不讨喜 2021-01-30 15:03

I\'m looking for a solution that can save me from maintaining two versions of the same image, one for Retina displays (aka @2x), one another for non-Retina displays. My goal is

9条回答
  •  伪装坚强ぢ
    2021-01-30 15:36

    This is quite an old thread, but I stumbled onto it, so I can elaborate on maintaining more than one size automatically.

    Performance-wise, I'm not sure using the automatic downscaling is a wise idea, as it has to be done in real-time, but it should work on simpler cases.

    Now, to convert these @2ximages automatically, a simple bash script should do the trick. l4u's solution works, but for guys with simpler needs who do not want to install guard, this also works (you still need to install ImageMagick, though) :

    for f in $(find . -name '*@2x.png'); do
        echo "Converting $f..."
        convert "$f" -resize '50%' "$(dirname $f)/$(basename -s '@2x.png' $f).png"
    done
    

提交回复
热议问题