User Tools

This is an old revision of the document!


Imagemagick

web optimizer

source : https://www.smashingmagazine.com/2015/06/efficient-image-resizing-with-imagemagick/

#!/bin/bash
if [ $# -lt 3 ];then
  echo $"missing arguments"
  exit 1;
fi

# arg 1 : source file
if [ ! -f $1 ]; then
	echo $"file $1 not found"
	exit 1;
fi

# arg 2 : width
re='^[0-9]+$'
if ! [[ $2 =~ $re ]] ; then
   echo "error: Not a number" >&2; exit 1
fi

# arg 3 : output folder
if [ ! -d $3 ]; then
	echo $"folder $3 not found"
	exit 1;
fi

mogrify -path $3 -filter Triangle -define filter:support=2 -thumbnail $2 -unsharp 0.25x0.08+8.3+0.045 -dither None -posterize 136 -quality 82 -define jpeg:fancy-upsampling=off -define png:compression-filter=5 -define png:compression-level=9 -define png:compression-strategy=1 -define png:exclude-chunk=all -interlace none -colorspace sRGB $1
use :
for filename in *.jpg; do optimizer.sh $filename 1024 outfolder;done

Images to pdf

note : https://stackoverflow.com/questions/52998331/imagemagick-security-policy-pdf-blocking-conversion

edit /etc/ImageMagick-6/policy.xml

<policy domain="coder" rights="read | write" pattern="PDF" />
and then
convert *.jpg mypdffile.pdf

This website uses cookies. By using the website, you agree with storing cookies on your computer. Also, you acknowledge that you have read and understand our Privacy Policy. If you do not agree, please leave the website.

More information