A single <img src="script.php"> can only show a single image.  If your
script.php generates two complete images, then I would think the browsers
would choke, but perhaps they fail gracefully and only show you the first
one.  If you want two images, you need 2 <img src...> tags and thus two
calls to your resizing script.

As for saving the images to disk, see the documentation for imagejpeg().
It takes a second optional parameter which is the filename to save the
image as.

-Rasmus

On Sat, 5 Apr 2003, Fedde wrote:

> heyas
> i have the following code to resize an image to any wanted size:
> <?
> //$image2 = "image.jpg";
> function resizeThatPic($image2){
>       $maxheight = 100;
>       $maxwidth = 100;
>       $size = getimagesize ("$image2");
>       $ratio = ($maxheight/$size[1]);
>       $constrain_width = ($ratio * $size[0]);
>       $constrain_height = ($ratio * $size[1]);
>       if ($constrain_width > $maxwidth){
>               $mess = ($maxwidth/$size[0]);
>               $constrain_width = ($ratio * $size[0]);
>               $constrain_height = ($ratio * $size[1]);
>       }
>       $image = imagecreate($constrain_width,$constrain_height);
>       $colorblue = imagecolorallocate($image, 0, 0, 255);
>       imagefill($image, 0,0, $colorblue);
>
>       if(!($image2 = @imagecreatefromjpeg("$image2"))){
>               $image = imagecreate($constrain_width,$constrain_height);
>               $colorwhite = imagecolorallocate($image, 255, 255, 255);
>               $colorblack = imagecolorallocate($image, 0, 0, 0);
>               imagefill($image, 0, 0, $colorwhite);
>               imagestring($image, 4, 10, 10, "Couldn't load image!", $colorblack);
>               header("Content-type: image/jpeg");
>               imagejpeg($image);
>               exit();
>       }
>
>       imagecopyresized($image, $image2 , 0, 0, 0, 0, $constrain_width,
> $constrain_height, imagesx($image2), imagesy($image2));
>       header ("Content-type: image/jpeg");
>       imagejpeg($image);
> }
> ?>
>
> question 1:
> I want to use this in an other page:
> <?
> require ("imagetest.php");
> resizeThatPic("image.jpg");
> resizeThatPic("image2.jpg");
> ?>
> The problem is that this only shows a resized image.jpg and no image2.jpg
> at all, why is that? and what can i do about it?
>
> question 2:
> Is there a way to save the resized image to another directory on the server?
>
> Thanks in advance :)
>
> Fedde
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

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

Reply via email to