DJ Mike's Tutorials: PHP

ImageMagick Functions

^

Imagick::setImageVirtualPixelMethod

Description:
bool Imagick::setImageVirtualPixelMethod ( int $method )

Changes how the pixels that fall off the edges of an image are handled when it is distorted.
Parameters:
method
imagick::VIRTUALPIXELMETHOD_UNDEFINED
imagick::VIRTUALPIXELMETHOD_BACKGROUND
Virtual pixels are set to the image background color
imagick::VIRTUALPIXELMETHOD_CONSTANT
imagick::VIRTUALPIXELMETHOD_EDGE
Virtual pixels are set to the color of the nearest edge
imagick::VIRTUALPIXELMETHOD_MIRROR
Virtual pixels mirror the image
imagick::VIRTUALPIXELMETHOD_TILE
Virtual pixels are set to tile the image
imagick::VIRTUALPIXELMETHOD_TRANSPARENT
Virtual pixels are set to transparent for GIF's and PNG's, black for JPEG's
Return Values
Returns TRUE on success.

Example



Background


<?php 
$image 
= new imagick"opossum.jpg" ); 
$points = array( 
                
0,025,25# top left  
                
176,0126,0# top right
                
0,1350,105# bottom right 
                
176,135176,135 # bottum left
                
);
$image->setimagebackgroundcolor("blue");
$image->setImageVirtualPixelMethodimagick::VIRTUALPIXELMETHOD_BACKGROUND );
$image->distortImageImagick::DISTORTION_PERSPECTIVE$pointsTRUE ); 
header"Content-Type: image/jpeg" ); 
echo 
$image;
?>

Edge


<?php 
$image 
= new imagick"opossum.jpg" ); 
$points = array( 
                
0,025,25# top left  
                
176,0126,0# top right
                
0,1350,105# bottom right 
                
176,135176,135 # bottum left
                
);
$image->setImageVirtualPixelMethodimagick::VIRTUALPIXELMETHOD_EDGE );
$image->distortImageImagick::DISTORTION_PERSPECTIVE$pointsTRUE ); 
header"Content-Type: image/jpeg" ); 
echo 
$image;
?>

Mirror


<?php 
$image 
= new imagick"opossum.jpg" ); 
$points = array( 
                
0,025,25# top left  
                
176,0126,0# top right
                
0,1350,105# bottom right 
                
176,135176,135 # bottum left
                
);
$image->setImageVirtualPixelMethodimagick::VIRTUALPIXELMETHOD_MIRROR );
$image->distortImageImagick::DISTORTION_PERSPECTIVE$pointsTRUE ); 
header"Content-Type: image/jpeg" ); 
echo 
$image;
?>

Tile


<?php 
$image 
= new imagick"opossum.jpg" ); 
$points = array( 
                
0,025,25# top left  
                
176,0126,0# top right
                
0,1350,105# bottom right 
                
176,135176,135 # bottum left
                
);
$image->setImageVirtualPixelMethodImagick::VIRTUALPIXELMETHOD_TILE );
$image->distortImageImagick::DISTORTION_PERSPECTIVE$pointsTRUE ); 
header"Content-Type: image/jpeg" ); 
echo 
$image;
?>

Transparent


<?php 
$image 
= new imagick"opossum.jpg" ); 
$points = array( 
                
0,025,25# top left  
                
176,0126,0# top right
                
0,1350,105# bottom right 
                
176,135176,135 # bottum left
                
);
$image->setImageVirtualPixelMethodimagick::VIRTUALPIXELMETHOD_TRANSPARENT );
$image->distortImageImagick::DISTORTION_PERSPECTIVE$pointsTRUE ); 
header("Content-type: image/jpeg");
echo 
$image;
?>


^


Was this webpage useful to you? You can support this website by donating.


Created by DJ Mike from Santa Barbara

DJ Mike


<a href="http://www.statcounter.com/" target="_blank"> <img src="http://c5.statcounter.com/counter.php?sc_project=1321035&java=0&security=da2193dc" alt="counter free hit invisible" border="0" /></a>