Centering the x and y ratio in images
I want to be able to figure out how to center images, by their x, y ratios using imagecopyresampled. How would I do this?
||03-12-2008 10:39 AM
One way you can find the center point of an image is to find the width and height and divide by 2
$size = getimagesize($filename);
$width = $size;
$height = $size;
$x = $width / 2;
$y = $height / 2;
Thats the way i have always done it anyway
You can always look at something like this
// The file
$filename = 'test.jpg';
$percent = 0.5;
// Content type
// Get new dimensions
list($width, $height) = getimagesize($filename);
$new_width = $width * $percent;
$new_height = $height * $percent;
$image_p = imagecreatetruecolor($new_width, $new_height);
$image = imagecreatefromjpeg($filename);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
imagejpeg($image_p, null, 100);
||03-12-2008 02:04 PM
There you have it, from the resident GD guru himself! x
||03-12-2008 03:04 PM
Lol :-) Rendair loves his GD, doesn't he.
$_GET['w'] and $_GET['h'] are defined xD
plus my images are from db
|All times are GMT. The time now is 12:23 AM.
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0