Activity Stream
48,167 MEMBERS
6816 ONLINE
besthostingforums On YouTube Subscribe to our Newsletter besthostingforums On Twitter besthostingforums On Facebook besthostingforums On facebook groups

Results 1 to 4 of 4
  1.     
    #1
    Banned
    Website's:
    WarezRelease.org ThatHosting.co

    Default remote 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 ) {
            
                
    $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$newThumbImg0000$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: 
    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

  2.   Sponsored Links

  3.     
    #2
    Respected Member
    Website's:
    DL4Everything.com Soft2050.in
    A 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 ) {
                 
    $newW $thumbPixels;
                
    $newH $thumbPixels $ratio;
        } else {
                
                
    $newH $thumbPixels;
                
    $newW $thumbPixels $ratio;
        }
        
        
    //function for resize image.

        
    if ( function_exists 'imagecreatetruecolor' ) ) {

                
    $newImg imagecreatetruecolor($newW25);
        } else {

                die(
    "Error: Please make sure you have GD library ver 2+");
        }

        
    //the resizing is going on here!

        
    imagecopyresized($newImg$newThumbImg0000$newW$newH$width2$height2);
        
        
    $imageFileClean preg_replace("/Resource id #6/"""$newname);
        
    //finally, save the image
        
        
    ImageJpeg ($newImg"abcd.png");
         
        
    ImageDestroy ($newImg);
        
    ImageDestroy ($newThumbImg);  
    ?>
    In Your Code:

    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); } 
    You are changing the fileurl before it could create image from the given url

    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); } 
    Note: Changing of $fileURL to $url to create image [imagecreatefromgif(imgurl)] so that it gets the image

  4.     
    #3
    Banned
    Website's:
    WarezRelease.org ThatHosting.co
    This 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 ) {
                 
    $newW $thumbPixels;
                
    $newH $thumbPixels $ratio;
        } else {
                
                
    $newH $thumbPixels;
                
    $newW $thumbPixels $ratio;
        }
        
        
    //function for resize image.

        
    if ( function_exists 'imagecreatetruecolor' ) ) {

                
    $newImg imagecreatetruecolor($newW25);
        } else {

                die(
    "Error: Please make sure you have GD library ver 2+");
        }

        
    //the resizing is going on here!

        
    imagecopyresized($newImg$newThumbImg0000$newW$newH$width2$height2);
        
        
    $imageFileClean preg_replace("/Resource id #6/"""$newname);
        
    //finally, save the image
        
        
    ImageJpeg ($newImg"abcd.png");
         
        
    ImageDestroy ($newImg);
        
    ImageDestroy ($newThumbImg); 
    im still getting errors:

    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?

  5.     
    #4
    Banned
    Website's:
    WarezRelease.org ThatHosting.co
    apologies, Soft2050.

    it was working, i just didnt realize it was saving to the root, anyways all is cool now, slightly modified............ thx

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. php resize
    By Chris2k in forum Web Development Area
    Replies: 11
    Last Post: 14th Jul 2011, 02:37 PM
  2. Looking for some new Image resize mod
    By Spartan in forum phpBB
    Replies: 1
    Last Post: 27th May 2011, 08:58 AM
  3. Image resize in DLE
    By John in forum Webmaster Discussion
    Replies: 1
    Last Post: 30th Dec 2010, 01:31 AM
  4. PHP Resize?
    By bxflow in forum Web Application/Script Support
    Replies: 5
    Last Post: 7th Sep 2010, 03:36 PM
  5. how to resize image in DL
    By loverhaker in forum Forum and DDL Discussion
    Replies: 0
    Last Post: 28th Aug 2010, 01:48 AM

Tags for this Thread

BE SOCIAL