Hi I need to upload two resized images out from one jpg image. I use 
following code to do it:

<?php
$nw=100; //The Width Of The Thumbnails
//$rn=400

$ipath = "./pics"; //Path To Place Where Images Are Uploaded.
$tpath = "./thumbs";//Path To Place Where Thumbnails Are Uploaded

function LoadJpeg ($imgname) {
   $im = @imagecreatefromjpeg ($imgname); /* Attempt to open */
   if (!$im) { /* See if it failed */
       $im  = imagecreate (150, 30); /* Create a blank image */
       $bgc = imagecolorallocate ($im, 255, 255, 255);
       $tc  = imagecolorallocate ($im, 0, 0, 0);
       imagefilledrectangle ($im, 0, 0, 150, 30, $bgc);
       /* Output an errmsg */
       imagestring ($im, 1, 5, 5, "Error loading $imgname", $tc);
   }
   return $im;
}

$dimensions = getimagesize($file);

$thname = "$tpath/$file_name";
//$rname = "$ipath/$file_name";

$w=$dimensions[0];
$h=$dimensions[1];

$c=$nw/$w;
//$c2=$rw/w;
$nh=$h*$c; //The Height Of The Thumbnails
//$rh=$h*$c2; //The Height Of The Large Pictures

$img = LoadJpeg($file);
//$img2 = LoadJpeg($file);
$thumb = imagecreatetruecolor($nw,$nh);
//$large = imagecreatetruecolor($rw,$rh);

        imagecopyresampled($thumb,$img,0,0,0,0,$nw,$nh,$w,$h);
//      imagecopyresampled($large,$img2,0,0,0,0,$rw,$rh,$w,$h);
        imagejpeg($thumb,$thname,95);
//      imagejpeg($large,$rname,95);

imagedestroy($img2);
?>
This code is working perfectly but produces only one uploaded and 
resized image (I comented out the lines that I add for second image) 
If I take out comments from the code on the second image - this 
script doesn't work - it produces two files on the server but only 
one of them is working the other one shows error of wrong hedding. 
How should I upload two resized files? I know it's possible but how 
can I fit everything in one portion of code?

Yury

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

Reply via email to