Cruisecar Posted March 5, 2007 Share Posted March 5, 2007 I've been making a roulette script that basicly spins the image in PHP (a roulette wheel), it's working fine except sometimes the image becomes bigger than I want it, the actuall roulette wheel remains the same size. It's obviously because the corners of the image are now extending over the borders, so PHP then compensates for this and fills in the rest of the background. (I hope i'm making sense so far). I want the image to either not be extended over 269x269 in the first place, or to be cropped after rotation. Can anybody help me do this? Here is a sample of the current rotation code. It all goes wrong on the imagecopyresampled() part. $original = "../images/wheel.jpg"; $original = imagecreatefromjpeg($original); $angle = $angles[$num]; $bgColour = 0x2F2F2F; $rotated = imagerotate($original, $angle, $bgColour); $cwd = getcwd(); $tempfile = tempnam("$cwd/tmp", "temp_image_"); $temphandle = fopen($tempfile, "w"); fwrite($temphandle, $rotated); fclose($temphandle); list($width, $height) = getimagesize($tempfile); // imagecopyresampled($rotated, $rotated, 0, 0, 0, 0, "269", "269", $width, $height); imagejpeg($rotated); unlink($tempfile); I hope someone can help me! Thankyou Link to comment https://forums.phpfreaks.com/topic/41348-image-cropping/ Share on other sites More sharing options...
Cruisecar Posted March 5, 2007 Author Share Posted March 5, 2007 imagecopyresampled($rotated, $rotated, 0, 0, 0, 0, "269", "269", $width, $height); I basicly just need a replacement for this, that will crop the image to 269x269. It's commented out at the moment as this solution doesn't work. Link to comment https://forums.phpfreaks.com/topic/41348-image-cropping/#findComment-200356 Share on other sites More sharing options...
fert Posted March 5, 2007 Share Posted March 5, 2007 imagecopyresampled($rotated, $rotated, 0, 0, 0, 0, 269, 269, $width, $height); Link to comment https://forums.phpfreaks.com/topic/41348-image-cropping/#findComment-200358 Share on other sites More sharing options...
Cruisecar Posted March 5, 2007 Author Share Posted March 5, 2007 $cwd = getcwd(); $tempfile = tempnam("$cwd/tmp", "temp_image_"); $temphandle = fopen($tempfile, "w"); fwrite($temphandle, $rotated); fclose($temphandle); list($width, $height) = getimagesize($tempfile); The $width and $height variables don't seem to contain any values, is there any easier way to get the image size? Link to comment https://forums.phpfreaks.com/topic/41348-image-cropping/#findComment-200370 Share on other sites More sharing options...
Cruisecar Posted March 6, 2007 Author Share Posted March 6, 2007 :tup: Link to comment https://forums.phpfreaks.com/topic/41348-image-cropping/#findComment-200626 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.