Results 1 to 4 of 4
-
18th Jul 2011, 09:50 PM #1OPBannedWebsite's:
WarezRelease.org ThatHosting.coremote imge resize
heyya,
im tryna resize a remote image with no luck, heres my code,
PHP Code:$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);
Code:Notice: Undefined variable: newThumbImg in C:\wamp\www\includes\imageupload.php on line 288 Warning: imagecopyresized() expects parameter 2 to be resource, null given in C:\wamp\www\includes\imageupload.php on line 288 Notice: Undefined variable: newThumbImg in C:\wamp\www\includes\imageupload.php on line 296 Warning: imagedestroy() expects parameter 1 to be resource, null given in C:\wamp\www\includes\imageupload.php on line 296
The same ^^ code is working for local images... so any1 can help?
Chris2k Reviewed by Chris2k on . remote imge resize heyya, im tryna resize a remote image with no luck, heres my code, $pixels = getimagesize($url); // Get image size in pixels for remote. $width2 = $pixels; $height2 = $pixels; //Make a 90x90px thumbnail...... Rating: 5
-
19th Jul 2011, 01:10 PM #2Respected MemberWebsite's:
DL4Everything.com Soft2050.inA fixed code for resizing from remote images:
PHP Code:<?php
$fileURL = 'http://www.besthostingforums.com/images/logo.png';
$pixels = getimagesize($fileURL); // Get image size in pixels for remote.
$width2 = $pixels[0];
$height2 = $pixels[1];
$thumbPixels = 90;
$newnam = 'KWWHsasdsa.png';
//Make a 90x90px thumbnail......
//echo $fileURL;
$newThumbImg = imagecreatefrompng($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, 25);
} 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, "abcd.png");
ImageDestroy ($newImg);
ImageDestroy ($newThumbImg);
?>
PHP Code://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); }
Replace the above code with this code:
PHP Code://Make a 90x90px thumbnail......
$fileURL = ($uploadDir . '/' . $newname);
//echo $fileURL;
if ($exten == "image/pjpeg" || $exten == "image/jpeg") { $newThumbImg = imagecreatefromjpeg($url); }
if ($exten == "image/x-png" || $exten == "image/png") { $newThumbImg = imagecreatefrompng($url); }
if ($exten == "image/gif") { $newThumbImg = imagecreatefromgif($url); }
-
19th Jul 2011, 01:43 PM #3OPBannedWebsite's:
WarezRelease.org ThatHosting.coThis is what ive got now:
PHP Code://Make a 90x90px thumbnail......
$fileURL = ($uploadDir . '/' . $newname);
//echo $fileURL;
if ($exten == "image/pjpeg" || $exten == "image/jpeg") { $newThumbImg = imagecreatefromjpeg($url); }
if ($exten == "image/x-png" || $exten == "image/png") { $newThumbImg = imagecreatefrompng($url); }
if ($exten == "image/gif") { $newThumbImsge = imagecreatefromgif($url); }
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, 25);
} 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, "abcd.png");
ImageDestroy ($newImg);
ImageDestroy ($newThumbImg);
Code:Notice: Undefined variable: ratio in C:\wamp\www\includes\imageupload.php on line 266 Notice: Undefined variable: ratio in C:\wamp\www\includes\imageupload.php on line 272 Warning: imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions in C:\wamp\www\includes\imageupload.php on line 279 Notice: Undefined variable: newThumbImg in C:\wamp\www\includes\imageupload.php on line 287 Warning: imagecopyresized() expects parameter 1 to be resource, boolean given in C:\wamp\www\includes\imageupload.php on line 287 Warning: imagejpeg() expects parameter 1 to be resource, boolean given in C:\wamp\www\includes\imageupload.php on line 292 Warning: imagedestroy() expects parameter 1 to be resource, boolean given in C:\wamp\www\includes\imageupload.php on line 294 Notice: Undefined variable: newThumbImg in C:\wamp\www\includes\imageupload.php on line 295 Warning: imagedestroy() expects parameter 1 to be resource, null given in C:\wamp\www\includes\imageupload.php on line 295
any ideas?
-
19th Jul 2011, 02:16 PM #4OPBannedWebsite's:
WarezRelease.org ThatHosting.coapologies, Soft2050.
it was working, i just didnt realize it was saving to the root, anyways all is cool now, slightly modified............ thx
Sponsored Links
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Similar Threads
-
php resize
By Chris2k in forum Web Development AreaReplies: 11Last Post: 14th Jul 2011, 02:37 PM -
Looking for some new Image resize mod
By Spartan in forum phpBBReplies: 1Last Post: 27th May 2011, 08:58 AM -
Image resize in DLE
By John in forum Webmaster DiscussionReplies: 1Last Post: 30th Dec 2010, 01:31 AM -
PHP Resize?
By bxflow in forum Web Application/Script SupportReplies: 5Last Post: 7th Sep 2010, 03:36 PM -
how to resize image in DL
By loverhaker in forum Forum and DDL DiscussionReplies: 0Last Post: 28th Aug 2010, 01:48 AM
themaLeecher - leech and manage...
Version 5.03 released. Open older version (or...