Rubblewebs

THESE CODES ARE PROVIDED FOR AN EXAMPLE OF HOW TO USE IMAGEMAGICK WITH PHP. CARE SHOULD BE TAKEN WHEN ACCEPTING USER INPUT.

I TAKE NO RESPONSABILTY FOR ANY PROBLEMS THAT MAY OCCURE WHEN USING ANY OF THIS CODE.

IT IS UP TO YOU TO SECURE THE CODE AND VALIDATE USER INPUT.

Resize options

Area

Resize image to have specified area in pixels. Aspect ratio is preserved.

Area example
$cmd = "$input -resize 10000@ "; 
exec("convert $cmd area.jpg");

Aspect ratio ignored

Width and height emphatically given, original aspect ratio ignored.

Aspect ratio ignored example
$cmd = "$input -resize 100x100! "; 
exec("convert $cmd ignored.jpg");

Both exceded

Change dimensions only if both image dimensions exceed specified dimensions.

Both exceded example
$cmd = "$input -resize \"100x100<\" "; 
exec("convert $cmd both_exceded.jpg");

Dimensions exceded

Change as per widthxheight but only if an image dimension exceeds a specified dimension.

Dimensions exceded example
$cmd = "$input -resize \"100x100>\" "; 
exec("convert $cmd exceded.jpg");

Equal percent

Height and width both scaled by specified percentage.

Equal percent example
$cmd = "$input -resize 50% "; 
exec("convert $cmd equal_percent.jpg");

Maximium dimensions

Maximum values of height and width given, aspect ratio preserved.

Maximium dimensions example
$cmd = "$input -resize 100x100"; 
exec("convert $cmd resize_max.jpg");

Resize height

Height given, width automagically selected to preserve aspect ratio.

Resize height example
$cmd = "$input -resize x100"; 
exec("convert $cmd resize_height.jpg");

Resize minimium

Minimum values of width and height given, aspect ratio preserved.

Resize minimium example
$cmd = "$input -resize \"100x100^\" "; 
exec("convert $cmd resize_min.jpg");

Resize width

Width given, height automagically selected to preserve aspect ratio.

Resize width example
$cmd = "$input -resize 100"; 
exec("convert $cmd resize_width.jpg");

Unequal percent

Height and width individually scaled by specified percentages. (Only one % symbol needed.)

Unequal percent example
$cmd = "$input -resize 100x50% "; 
exec("convert $cmd unequal_percent.jpg");