eZe616 Posted May 23, 2007 Share Posted May 23, 2007 I'm trying this simple script to resize an image, but it won't work. The file keeps giving me this as output: ' http://localhost/res/cms/img.php ' Here's my script: <?php $src = ImageCreateFromJPEG('1.jpg'); list($width,$height) = getimagesize($src); $x = .5 * $width; $y = .5 * $height; $dst = ImageCreateTrueColor($x,$y); ImageCopyResampled($dst,$src,0,0,0,0,$x,$y,$width,$height); header('Content-Type: image/jpeg'); imagejpeg($dst); ?> Quote Link to comment https://forums.phpfreaks.com/topic/52723-solved-easy-resizing-image-problem/ Share on other sites More sharing options...
Barand Posted May 23, 2007 Share Posted May 23, 2007 if that file above is "img.php" then, in another page, put <img src="img.php"> to display the resized image. And don't forget to imagedestroy($src); imagedestroy($dst); at the end of img.php to release the memory. Quote Link to comment https://forums.phpfreaks.com/topic/52723-solved-easy-resizing-image-problem/#findComment-260334 Share on other sites More sharing options...
eZe616 Posted May 23, 2007 Author Share Posted May 23, 2007 Hey thanks, but i'm not getting the resized image to display Quote Link to comment https://forums.phpfreaks.com/topic/52723-solved-easy-resizing-image-problem/#findComment-260347 Share on other sites More sharing options...
Barand Posted May 23, 2007 Share Posted May 23, 2007 list($width,$height) = getimagesize($src); change to list($width,$height) = getimagesize('1.jpg'); OR $width = imagesx($src); $height = imagesy($src); Quote Link to comment https://forums.phpfreaks.com/topic/52723-solved-easy-resizing-image-problem/#findComment-260352 Share on other sites More sharing options...
eZe616 Posted May 23, 2007 Author Share Posted May 23, 2007 still nothing...you think maybe it's my php configuration?...it's not supposed to be, since I can see my gb in the phpinfo, and the files are enabled Quote Link to comment https://forums.phpfreaks.com/topic/52723-solved-easy-resizing-image-problem/#findComment-260363 Share on other sites More sharing options...
Guardian-Mage Posted May 23, 2007 Share Posted May 23, 2007 When displaying it with HTML, couldn't you set the width and height to the appropriate values? -Brandon Quote Link to comment https://forums.phpfreaks.com/topic/52723-solved-easy-resizing-image-problem/#findComment-260369 Share on other sites More sharing options...
Barand Posted May 23, 2007 Share Posted May 23, 2007 comment out the header() statement and call it direct. see if it gives an error Quote Link to comment https://forums.phpfreaks.com/topic/52723-solved-easy-resizing-image-problem/#findComment-260370 Share on other sites More sharing options...
eZe616 Posted May 24, 2007 Author Share Posted May 24, 2007 When displaying it with HTML, couldn't you set the width and height to the appropriate values? -Brandon still get a broken image. I'd rather resize the image. comment out the header() statement and call it direct. see if it gives an error Still nothing, all I get is a broken image sign in IE, and nothing in FF. Quote Link to comment https://forums.phpfreaks.com/topic/52723-solved-easy-resizing-image-problem/#findComment-260386 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.