heyya,
im tryna resize a remote image with no luck, heres my code,
and im getting these errors:
The same ^^ code is working for local images... so any1 can help?
[/B]
im tryna resize a remote image with no luck, heres my code,
PHP:
$pixels = getimagesize($url); // Get image size in pixels for remote.
$width2 = $pixels[0];
$height2 = $pixels[1];
//Make a 90x90px thumbnail......
$fileURL = ($uploadDir . '/' . $newname);
//echo $fileURL;
if ($exten == "image/pjpeg" || $exten == "image/jpeg") { $newThumbImg = imagecreatefromjpeg($fileURL); }
if ($exten == "image/x-png" || $exten == "image/png") { $newThumbImg = imagecreatefrompng($fileURL); }
if ($exten == "image/gif") { $newThumbImg = imagecreatefromgif($fileURL); }
$ratio = $width2 / $height2; // calculate the ratio
if ($ratio > 1 ) {
$newW = $thumbPixels;
$newH = $thumbPixels / $ratio;
} else {
$newH = $thumbPixels;
$newW = $thumbPixels * $ratio;
}
//function for resize image.
if ( function_exists ( 'imagecreatetruecolor' ) ) {
$newImg = imagecreatetruecolor($newW, $newH);
} else {
die("Error: Please make sure you have GD library ver 2+");
}
//the resizing is going on here!
imagecopyresized($newImg, $newThumbImg, 0, 0, 0, 0, $newW, $newH, $width2, $height2);
$imageFileClean = preg_replace("/Resource id #6/", "", $newname);
//finally, save the image
ImageJpeg ($newImg, $thumbDir . $newname);
ImageDestroy ($newImg);
ImageDestroy ($newThumbImg);
and im getting these errors:
Code:
[B]Notice[/B]: Undefined variable: newThumbImg in [B]C:\wamp\www\includes\imageupload.php[/B] on line [B]288[/B]
[B]Warning[/B]: imagecopyresized() expects parameter 2 to be resource, null given in [B]C:\wamp\www\includes\imageupload.php[/B] on line [B]288[/B]
[B]Notice[/B]: Undefined variable: newThumbImg in [B]C:\wamp\www\includes\imageupload.php[/B] on line [B]296[/B]
[B]Warning[/B]: imagedestroy() expects parameter 1 to be resource, null given in [B]C:\wamp\www\includes\imageupload.php[/B] on line [B]296
The same ^^ code is working for local images... so any1 can help?
[/B]