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.

Imagick Functions page: 20

Set image interpolate method

Sets the image interpolate pixel method.

Set image interpolate method example
$im = new Imagick ($input);
$im->setImageInterpolateMethod( imagick::INTERPOLATE_AVERAGE );
$im->writeImage('setImageInterpolateMethod.jpg'); 
$im->destroy();

Set image matte

Sets the image matte channel.

Set image matte example
$im = new imagick( $input ); 
$corners = array( 0,0, 0,0, 200,0, 200,30, 200,150, 200,120, 0,150, 0,150 );
$im->setImageVirtualPixelMethod( Imagick::VIRTUALPIXELMETHOD_TRANSPARENT );
$im->setImageMatte( TRUE );
$im->distortImage( Imagick::DISTORTION_PERSPECTIVE, $corners, TRUE ); 
$im->writeImage('setImageMatte.png'); 
$im->destroy();

Set image matte color

Sets the image matte color.

Set image opacity

Sets the image to the specified opacity level.

Set image opacity example
$im = new imagick( $image );
$im->setImageOpacity(0.5);
$im->writeImage('setImageOpacity.png'); 
$im->destroy();

Set image orientation

Sets the image orientation.

$im = new imagick( $image );
$im->setImageOrientation(imagick::ORIENTATION_TOPLEFT );
$im->writeImage('setImageOrientation.jpg'); 
$im->destroy();

( Doesn't actually rotate the image, it just changes the EXIF rotation info that will be saved with the image. )

Set image page

Sets the page geometry of the image.

Set image profile

Adds a named profile to the Imagick object.


( If a profile with the same name already exists, it is replaced. This method differs from the ProfileImage() method in that it does not apply any CMS color profiles. )

Set image property

Sets a named property to the image.

The EXIF make is now set to Imagick

$im = new Imagick();
$im->newImage(300, 200, "black");
$im->setImageProperty('Exif:Make', 'Imagick');
echo $im->getImageProperty('Exif:Make');

Set image red primary

Sets the image chromaticity red primary point.

Set image rendering intent

Sets the image rendering intent.

Set image resolution

Sets the image resolution.

$imagick = new \Imagick();
$imagick->readImage($path);
$imagick->Imagick::setImageResolution( 600, 600 );
$imagick->resizeImage(595,842,\Imagick::FILTER_CATROM, 1, true);
$imagick->setImageFormat('pdf');
$imagick->writeImage($endpath);

( Useful when working with a pdf file to adjust the quality. Similar to the Imagemagick -density operator )

Set image scene

Sets the image scene.

Set image ticks per second

Sets the image ticks-per-second.

Set image type

Sets the image type.

Set image type example
$im = new Imagick ($input);
$im->setImageType ( imagick::IMGTYPE_GRAYSCALE);
$im->writeImage('setImageType.jpg'); 
$im->destroy();

( Alternativly you could use this instead where 2 = grayscale:
$im->setImageType ( 2 ); )