Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

imagegif and imagejpeg

Status
Not open for further replies.

iamregistered

Programmer
Oct 3, 2006
27
SE
Greetings all,

I am working on a class to view images that are not stored in documentroot folders and the ability to create thumb-nails of the picture and saving them to a specific folder. The class is complete, but I've done a few changes to see the effects of it. But now I have stumbeld upon a problem, and I can't find the solution.
This is the code for displaying jpeg images:
It should be very easy to understand.

Code:
function output_jpeg()
{
    header("content-type: image/jpeg");
    header("Content-Length: ".filesize($this->load_from));
    $this->load_handle = imagecreatefromjpeg( $this->load_from );
    if( $this->make_thumb )
    {
        $this->create_handle = imagecreatetruecolor( $this->new_width,$this->new_height );
        imagecopyresized( $this->create_handle,$this->load_handle,0,0,0,0,$this->new_width,$this->new_height,$this->old_width,$this->old_height);
        if( $this->save_thumb )
        {
            imagejpeg($this->create_handle,$this->thumb_path.$this->filename,$this->thumb_quality);
        }
        imagejpeg($this->create_handle,"",$this->thumb_quality);
        imagedestroy( $this->create_handle );
    }
    else
    {
        imagejpeg( $this->load_handle );
    }
    imagedestroy( $this->load_handle );
}

The code for gif files are almost identical apart from the code where it keeps the transparency when creating thumb-nails.

The problem that occurs is as follows: When I call upon the class to display a picture, either gif och jpeg, the progressbar stops at about half completion and the image will not present it self. However, when I press ESC then the image will show up.

Anyone have an idea what might cause this problem of mine?
Could it be something in my code, something in php.ini or my server? Apache 2.0.59 and php 4.4.4.

**
En solnedgång här
Med björkens dalande löv
Mörkret närmar sig
**
 
Did it work before? if it did, its not in your php.ini file, you probably just made a mistake somewhere.

 
The imagegif is working fine now that I've added header content-type and content-length to it. However, imagejpeg isn't working. BUT when I remove content-length from it, then it works. Something else that I've found out is that when content-length is in the code then it works for files of smaller size. I've tried with one that is 18.6kb and it didn't work, but an img at 12.2 kb is working. This is driving me crazy.

**
En solnedgång här
Med björkens dalande löv
Mörkret närmar sig
**
 
I found the problem.

I change imagejpeg( $this->load_handle );
to imagejpeg( $this->load_handle,"", 100 );
and that solved that problem :)

**
En solnedgång här
Med björkens dalande löv
Mörkret närmar sig
**
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top