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.

Usefull snippets in no particular order

magick xc:Red[100x30!]
	

The default "canvas:" or "xc:" is a 1x1 pixel square. The bang "!" will cause the command to ignore the 1:1 aspect and force the resize to the 100x30 dimensions. When included in the code it will create a red canvas 100px x 30px

From here: Shortcut for default canvas

magick xc:Red[100x30!] show:
	

When run it will create a red canvas 100px x 30px and display it within the Imagemagick display window. Generaly used from a command line

magick -size 300x300 -define gradient:direction=east gradient:red-none eastWestGradient.png
magick -size 300x300 -define gradient:angle=45 gradient:red-none fortyFiveGradient.png
	

No need to draw a gradient and rotate it as in previous versions; the direction can now be set when it is created

From here: New gradiant methods

magick -ping IMAGE.jpg XMP:-
	

Displays the xmp data from a compatible file. Generaly used from a command line

system("magick -ping photo.jpg XMP:-");
	

This will display the XMP data on the page.

-ping will read the required data without loading the image and can be quicker

convert granite: rose: -background none -gravity south -smush -10 result.jpg
	

-smush is a undocumented feature that has some interesting features

From here: Smush

$size = exec("convert input.jpg -resize 50% -format \"%wx%h\" -write info: output.jpg ");
	
echo "new size = $size";
	

Display the new size of a resized image