PHP Thumbnail Fun

Discussion in 'PHP' started by audax, Nov 29, 2006.

  1. #1
    I'm encountering errors when trying to getimagesize() of a URL to an image.
    I'm using the thumbnail script from: http://forums.digitalpoint.com/showpost.php?p=329156&postcount=2
    The error:
    image.php
    function loadImage($path)
        /*
        This function loads the image you want to resize.
        The function will return TRUE on a succes and FALSE on failure
        */
        {
            if ( $this->image ) {
                imagedestroy($this->image);
            }
    
            $img_sz = getimagesize($path); //THIS IS LINE 54 FROM THE ERROR
            switch( $img_sz[2] ){
                case 1:
                    $this->image_type = "GIF";
                    if ( !($this->image = imageCreateFromGif($path)) ) {
                        return FALSE;
                    } else {
                        return TRUE;
                    }
                    break;
                case 2:
                    $this->image_type = "JPG";
                    if ( !($this->image = imageCreateFromJpeg($path)) ) {
                        return FALSE;
                    } else {
                        return TRUE;
                    }
                    break;
                case 3:
                    $this->image_type = "PNG";
                    if ( !($this->image = imageCreateFromPng($path)) ) {
                        return FALSE;
                    } else {
                        return TRUE;
                    }
                    break;
                case 4:
                    $this->image_type = "SWF";
                    if ( !($this->image = imageCreateFromSwf($path)) ) {
                        return FALSE;
                    } else {
                        return TRUE;
                    }
                    break;
                default:
                    return FALSE;
            }
        }
    PHP:

     
    audax, Nov 29, 2006 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
  3. adsblog

    adsblog Active Member

    Messages:
    659
    Likes Received:
    27
    Best Answers:
    0
    Trophy Points:
    70
    #3
    check image path .
    is it protected by .htaccess ? or you upload image from url ?
     
    adsblog, Nov 30, 2006 IP
  4. audax

    audax Peon

    Messages:
    83
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Ah yea, it was .htaccess protected. Thanks for that :)

    I always overlook the smallest things lol.
     
    audax, Nov 30, 2006 IP
  5. audax

    audax Peon

    Messages:
    83
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    On a somewhat related note, I've got an issue when it comes to uploading a large image onto the server. Everything seems to work just fine until I try to upload an image larger than about 100KB. I know it's not the MAX_FILE_SIZE, as I've increased that much higher, but every time I try to upload a large image, I get an Internal Server Error 500. You would think it would be a web host problem, but would they really limit form uploads to 100KB? The code works just fine up until an image that size or larger is attempted to be uploaded.

    Someone else had the same problem as well:
    http://drupal.org/node/25176
     
    audax, Nov 30, 2006 IP