Image Controls - Distorting image
Posted: Tue Sep 11, 2007 5:49 pm
Could anyone tell me how to distort an image using image controls to give it a 3d perspective like the pic below?
Thanks in advance!

Thanks in advance!

A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/

I'm fine with that. I just don't even know where to begin. I've never used image controls before.feyd wrote:Not fun. You will have to do the 3D math yourself.
I wouldn't be. If you can write that sort of stuff with any ease you wouldn't be calling them "controls". Check out PEAR I believe there is a package especially designed for this kind of stuff, it has 3D in the title, shouldn't be hard to find.I'm fine with that.
Code: Select all
<?php
//Fake perspective transform
$source = imagecreatefromjpeg("image.jpg");
$width = imagesx($source);
$height = imagesy($source);
$destination = imagecreatetruecolor($width,$height);
$white = imagecolorallocate($destination,255,255,255);
imagefill($destination,0,0,$white);
for ($x = 0; $x<$width; $x++) {
imagecopyresampled($destination,$source,$x,($height/4)-(($height/$width)*$x/4),$x,0,1,($height/2)+(($height/$width)*$x/2),1,$height);
}
header("Content-type: image/jpeg");
imagejpeg($destination);
?>thanks onion you're a life saver.onion2k wrote:It can be faked using imagecopyresampled, but the result isn't really that good...
Code: Select all
<?php //Fake perspective transform $source = imagecreatefromjpeg("image.jpg"); $width = imagesx($source); $height = imagesy($source); $destination = imagecreatetruecolor($width,$height); $white = imagecolorallocate($destination,255,255,255); imagefill($destination,0,0,$white); for ($x = 0; $x<$width; $x++) { imagecopyresampled($destination,$source,$x,($height/4)-(($height/$width)*$x/4),$x,0,1,($height/2)+(($height/$width)*$x/2),1,$height); } header("Content-type: image/jpeg"); imagejpeg($destination); ?>
What image controls are you referring to? I've never heard of image controls before.elinews wrote:Do you know where/how I can download and install php imagecontrols on my apache server?