标签: imagemagick

  • 使用 imagemagick 压缩图片

    以Ubuntu为例,使用 imagemagick 压缩图片,

    首先安装 imagemagick

    apt install imagemagick

    若未找到,可以使用 apt update 更新后再安装,

    找出大于 5M 的 jpg 或者 png图片,使用 convert 命令结合 resize 参数进行压缩

    for f in $(find . -size +5M | grep -E "jpg|png$");do convert $f -resize 25% $f;done;
    
    for f in $(find . -size +4M | grep -E "jpg|png$");do convert $f -resize 30% $f;done;
    
    for f in $(find . -size +3M | grep -E "jpg|png$");do convert $f -resize 40% $f;done;
    
    for f in $(find . -size +2M | grep -E "jpg|png$");do convert $f -resize 45% $f;done;
    
    for f in $(find . -size +1M | grep -E "jpg|png$");do convert $f -resize 50% $f;done;