Re: problems with thumbnail image

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

 



On Friday 02 March 2007 21:59, Roberto Mansfield wrote:
> The problem is that your function generates thumbnail and then tries to
> return the binary image within the html document. Html contains *links*
> to images, not the images themselves. So you need to do something like
> this:
>
> <img src="create_thumbnail.php?filename=<? echo $photo_img_name; ?>">
>
> Then you create_thumbnail.php can return the binary image:
>
> <?
>
> // be sure to validate the user supplied parameter!
> $photo_img_name = $_REQUEST['filename'];
>
>
>  $percent = 0.5;
>  list($width, $height) = getimagesize($photo_img_name);
>  $newwidth = $width * $percent;
>  $newheight = $height * $percent;
>  $thumb = imagecreatetruecolor($newwidth, $newheight);
>  $source = imagecreatefrompng($photo_img_name);
>  imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight,
> $width,
> $height);
>
> // or whatever the correct mime/type is
> header("Content-type: image/png");
>
> echo imagepng($thumb);
> }
I assumed there are no problems with the html part of things as the original 
image was being display perfectly. Guess thats where the difference between 
newbies and old hands is evident. 

I have added the suggested validation. Many thanks for all the help.

regards
Punit Neb

-- 
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