Forum Moderators: coopster

Message Too Old, No Replies

Outputting graphics locking up Apache

         

Nutter

2:24 pm on Jun 16, 2006 (gmt 0)

10+ Year Member



I've got a script that is called from the src attribute of an <img> tag and is supposed to serve a graphic based on the query string. Ex:?size=thumbnail&id=123&color=bw will show the thumbnailed sized image of image id 123 in black and white. It works when called by itself, but when it is called several times on the same page the browser just hangs. And it only happens with thumbnails; it will work fine for fullsize image, but there's only one of those to a page.

Here's the basics of what the script does when a black and white thumbnail is called for.

1 - Checks to see if the bw thumbnail already exists in cache
2 - If it doesn't exist ImageMagick is called to convert the color thumbnail to grayscale and save it to cache
3 - File is opened from cache into fread()
4 - Header sent image/jpeg followed by the data from fread.

This works flawlessly on the two Linux servers (Apache 1.3 PHP4 / Apache 2 PHP4) I've tried it on, but on a WinXP server running Apache 2 / PHP5 the browser just sits and waits for images that never come. I let it run overnight last night just to see if it was working, but really slowly. Nothing.

After it does this I have to restart Apache to get the site working again.

dreamcatcher

10:51 pm on Jun 17, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi Nutter,

Just wondering. Are you using the getfilesize() function? I`ve heard some people have had problems with this function in the past in that it returns the problem you are encountering.

dc

Nutter

12:37 am on Jun 18, 2006 (gmt 0)

10+ Year Member



I assume you mean filesize(), and yes I am using it.
$fhandle = fopen($filename, "rb"); 
$dataout = fread($fhandle, filesize($filename));
fclose($fhandle);

What are the options? I'm fairly certain I need filesize() to tell fread how much to read. Is there a way to tell fread to read everything without using filesize()?

dreamcatcher

8:33 am on Jun 18, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Sorry, my fault, I meant the getimagesize [uk2.php.net] function.

dc

Nutter

12:29 pm on Jun 18, 2006 (gmt 0)

10+ Year Member



I'm using getimagesize, but not on the page that's causing the problems. It is getting used on the page before though.

coopster

3:36 pm on Jun 19, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Have a look at message number 3 in the Installing PHP5 Under Windows XP and Apache [webmasterworld.com] thread in our PHP Forum Library [webmasterworld.com]. It may very well be a server configuration issue.