foreach ($list as $pp) { //Thumbnail Creation $file = explode("/", $pp); $p = $file[1]; print $p; $new_w = '125'; $new_h = '125'; $size = GetImageSize($pp); $old_x = $size[0]; $old_y = $size[1]; if ($old_x > $old_y) { $thumb_w=$new_w; $thumb_h=$old_y*($new_h/$old_x); } if ($old_x < $old_y) { $thumb_w=$old_x*($new_w/$old_y); $thumb_h=$new_h; } if ($old_x == $old_y) { $thumb_w=$new_w; $thumb_h=$new_h; } echo 'Thumb Created Successfully!'; $dst_img = ImageCreateTrueColor($thumb_w,$thumb_h); $image = ImageCreateFromJPEG($pp); imagecopyresampled($dst_img,$image,0,0,0,0,$thumb_w,$thumb_h,$old_x,$old_y); imagejpeg($dst_img, $pics_folder.'_thb_'.$p, 100); //Full-Size Image Creation $new_w = '420'; $new_h = '420'; if ($old_x > $old_y) { $full_w=$new_w; $full_h=$old_y*($new_h/$old_x); } if ($old_x < $old_y) { $full_w=$old_x*($new_w/$old_y); $full_h=$new_h; } if ($old_x == $old_y) { $full_w=$new_w; $full_w=$new_h; } $dst_img = ImageCreateTrueColor($full_w,$full_h); $image = ImageCreateFromJPEG($pp); imagecopyresampled($dst_img,$image,0,0,0,0,$full_w,$full_w,$old_x,$old_y); imagejpeg($dst_img, $pics_folder.$p, 100); }