custom code to flip/mirror images
bara.munchies - July 21, 2009 - 07:51
| Project: | Imagecache Actions |
| Version: | 6.x-1.6 |
| Component: | Custom Actions Module |
| Category: | task |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Description
i am working on a website where i select some imported images to flip them for display. i do that to have all objects on the images to face in the same direction. i use flags to select some images and then use a different image cache preset. blahblahblah. anyhow, i use this custom code in a imagecache action. might be usefull for some ppl. credit goes to this website, were i adopted the code from:
http://www.planetsourcecode.com/vb/scripts/ShowCode.asp?txtCodeId=1876&l...
i have both vertically and horizontally flips in the code, so you need to comment out what you do not need:
here goes:
$size_x = imagesx($image->resource);
$size_y = imagesy($image->resource);
$temp = imagecreatetruecolor($size_x, $size_y);
//use this line to flip image vertically (upside-down)
//$x = imagecopyresampled($temp, $image->resource, 0, 0, 0, ($size_y-1), $size_x, $size_y, $size_x, 0-$size_y);
//use this line to flip image horizontally (right-left)
$x = imagecopyresampled($temp, $image->resource, 0, 0, ($size_x-1), 0, $size_x, $size_y, 0-$size_x, $size_y);
if ($x) {
$image->resource = $temp;
}