Image maintenance resizing KB. Free or paid cost dependant.

Started by jeffrey scott, August 15, 2009, 05:20:25 PM

Previous topic - Next topic

Gargoyle

Gotta be SMF.... I can upload a lil over a 2mb file with no issue...

Other users try to do a under 2mb file and it white screen of deaths every time.

This isn't good.

Kays

PHP does have a built in 2MB limit.

But I haven't really tried this on any very large images yet.

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

Gargoyle

Yeah I don't mind the 2mb limit... but the issue is the code doesn't seem to not post the image anymore so it breaks the thread until I go into phpmyadmin and manually remove the attachment.

It used to just not save it at all which it no longer does.. No idea why.

Kays

What size is the file  and what is the file format?

Have you got a screenshot?

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

Gargoyle

Screen shot would be a blank all white screen... Thats all ya get.. LOL!! So nothing to screen shot there..

They were all jpeg and varied in size. I kept the testing to 2mb and below which would result in timeouts or broken topics until I removed the image from the DB.

The system worked fine for my account which I found odd... No one else's would work even when I would use it.

Arantor

It isn't the fact that it's 2MB that's actually the problem.

As you probably know, JPEG is a lossy fileformat, meaning it loses content as you save - thus yielding better compression.

The problem likely stems from when you have file that overflows PHP's memory limit upon trying to load said file, or over the time limit allowed for processing.

Either way this should be recorded in the server error log.

jeffrey scott

Kays,

It works great on my test site, thanks. I am struggling to back up my main site so I can't update that one yet.

I'll keep you posted

Jeff

Gargoyle

Quote from: Arantor on October 05, 2009, 06:19:13 AM
It isn't the fact that it's 2MB that's actually the problem.

As you probably know, JPEG is a lossy fileformat, meaning it loses content as you save - thus yielding better compression.

The problem likely stems from when you have file that overflows PHP's memory limit upon trying to load said file, or over the time limit allowed for processing.

Either way this should be recorded in the server error log.

Then why does coppermine work ? With the same restriction and users... I find that puzzling.

Arantor

I have no knowledge of Coppermine but I suspect you provide the images yourself, not have remotely hosted ones, wherein the sizes are already known as they are held by the attachments system.

Kays

Quote from: jeffrey scott on October 05, 2009, 04:40:34 PM
Kays,

It works great on my test site, thanks. I am struggling to back up my main site so I can't update that one yet.

I'll keep you posted

Jeff

Thanks and good luck with the site.

Gargoyle
Try this and see if it helps.

In that last block of code in Display.php after:

if ( $height <= 0 && $width <= 0 )
return false;


Add:



@ini_set('memory_limit', '48M');



If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

Gargoyle

@ Kays -- With a @ sign ? Whats does the @ mean to php ??

Thanks I will try it! ;D


@ Arantor -- The point you are making has totally escaped me... lol... I honestly am not getting what you are saying.. ;D

Arantor

@ means it'll attempt to do it and if there's an error, don't log it.


I was thinking of a different thread with a similar question in at the time to be honest. The reason Coppermine works is because AFAIK it does resizing after doing the same code Kays demonstrates, and that's only after it's tried another method first (using imagemagick), meaning it isn't subject to the same memory limits. But SMF doesn't apply that because it doesn't work on all servers.

Gargoyle

Ah ok that makes more sense...

Okay Kays I just had a user try to upload a 1.7mb image file and it failed the same. Blank white screen with a Http 500 error.

Arantor


Gargoyle

What do you mean ?? It was your standard 500 error that shows up in IE... On Mozilla it shows nothing but a blank page. What info do you need and I will get it.

Arantor

Well, we need to know what the server (not SMF) forum error log says.

A 500 server error means many things, and it seems your server is set to not spit out errors, so until we see the error log we can't begin to diagnose what caused this.

Gargoyle

PHP Fatal error:  Allowed memory size of 50331648 bytes exhausted (tried to allocate 3188 bytes) in (omited info)

Found this in the server logs. Dunno how the hell he used that much memory when my file was larger...

Looking forward to educated responses as mine leave me wondering...

Arantor

A JPEG file is massively compressed. How many pixels wide by how many pixels high is that photo?

Gargoyle

I'm not sure.... I have asked him to email me the image so I can figure that out.

The last one I uploaded was 2500x2806 but I do recall having an issue with images in the 3000 range... Even when my account tried to upload them.

I wonder if there is a way to limit the dimensions accepted like there is the size with this mod in place.

Gargoyle

Okay I just did a 3030 x 2000 image that was 990kb and it went with no issue..

I guess what I really need here is a way for the forum to repair itself in the event an upload fails in a server error scenario. OR a way to adjust the mod to the limitations of the hosting perhaps ??

I mean using 48MB of total memory is pretty extreme for a single file don't you think ?

Advertisement: