I've wrttien a function to resize 3 images that are uploaded by the user into a temp folder.
I am using a while loop to go through the code 3 times.
I cant figure out why but only one image is resized and stored as image 1.
There is an if statement with in the while loop to select witch image to be resized, i think this may be causing my issue(i cant see why but is the only thing i can think might be.
I think this will be something simple that i am just not seeing but i cant figure it at all.
Any help would be great
cheers
Below is my code:
function image_handler($path1, $path2, $path3, $prod_id)
{
mkdir("../Images/small_product_image/$prod_id/");
mkdir("../Images/large_product_image/$prod_id/");
$c = 0;
while ($c <= 2)
{
if($c=0) {$image = $path1;}
else if($c=1) {$image = $path2;}
else $image = $path3;
$ext = substr($image, -3); //get extension
$x = @getimagesize($image); // get image size
$sw = $x[0]; // image width
$sh = $x[1]; // image height
$w = 150; //new width
$wb = 350; //new width for large image
$h = (100 / ($sw / $w)) * .01;
$h = @round ($sh * $h); //new hieght
$hb = (100 / ($sw / $wb)) * .01;
$hb = @round ($sh * $hb); //new hieght
$im = @ImageCreateFromJPEG ($image) or // Read JPEG Image
$im = @ImageCreateFromPNG ($image) or // or PNG Image
$im = @ImageCreateFromGIF ($image) or // or GIF Image
$im = false; // If image is not JPEG, PNG, or GIF
$thumb = @ImageCreateTrueColor ($w, $h); // Create the resized image destination
$thumbb = @ImageCreateTrueColor ($wb, $hb);
@ImageCopyResampled ($thumb, $im, 0, 0, 0, 0, $w, $h, $sw, $sh); // Copy from image source, resize it, and paste to image destination
@ImageCopyResampled ($thumbb, $im, 0, 0, 0, 0, $wb, $hb, $sw, $sh);
$filename = "../Images/small_product_image/$prod_id/$c.".$ext;
$filenameb = "../Images/large_product_image/$prod_id/$c.".$ext;
imagejpeg($thumb,$filename,100);
imagejpeg($thumbb,$filenameb,100);
$c++;
}
}