Jump to content

[SOLVED] easy resizing image problem


eZe616

Recommended Posts

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);
?>

Link to comment
https://forums.phpfreaks.com/topic/52723-solved-easy-resizing-image-problem/
Share on other sites

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.

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.