Re: outputing image part 2

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ross wrote:
I have manually put in the url my display_image.php page to debug as
sugested and all I get is the URL of the display_image.php page output on
the screen.

This is what I see
http://xxxxxxxxxxxxxxx.co.uk/common/display_image.php


this is the display_image.php file:

$img_url="http://www.xxxxxxxxxxxxx.co.uk/images/ENapt63377/4.jpg";;

This should almost certainly be a filename not a URL.

$image = imagecreatefromjpeg($img_url);
if ($image === false) { exit; }

// Get original width and height
echo $width = imagesx($image);
echo $height = imagesy($image);

// New width and height
$new_width = 200;
$new_height = 150;

// Resample
$image_resized = imagecreatetruecolor($new_width, $new_height);
imagecopyresampled($image_resized, $image, 0, 0, 0, 0, $new_width,
$new_height, $width, $height);

// Display resized image

header('Content-type: image/jpeg');

Comment out this header line. Chances are you're getting an error message, but because you're telling the browser it's an image the browser is trying to display it as an image. Because it can't, it's displaying the default alt tag which is the URL (assuming you're using Firefox which is the only browser I know of to do this).

imagejpeg($image_resized);
exit();

-Stut

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux