Error when uploading: image under 2mb

Hi all,

Am getting an error when uploading a 1.10mb picture. Details are:

The photo could not be uploaded: Unexpected error: Allowed memory size of 1342728 17bytes exhausted (tried to allocate 8192 bytes) in ImageResizer.php on line 52

Any ideas @Ben ?

Cheers
Chumby

Hi Chumby,

I hope 2022 is going well for you so far!

It looks like your message had a copy-and-paste error… Did you mean 134217728 bytes? That would correspond to 128 MB.
I haven’t looked into it lately, but the resizing would require something in the realm of two or three times the size of the image as a bitmap. You should be able to estimate that requirement by calculating width X height X bytes per pixel X 3. e.g. for a photo 6000x4000, that would be 3000x2000x3x3 = approximately 216 MB.

In any case, can you try increasing the PHP memory_limit setting to something like “256M”?

I’ve found that it’s possible to temporarily allow PHP to increase the memory limit for specific operations. I’ll see if I can add this into the upload function.

Cheers,
Ben

Hi Ben,

Yes all going well thanks. I just tried the upload again and you are right - the error size was 134217728 bytes…

“The photo could not be uploaded: Unexpected error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 8192 bytes) in ImageResizer.php on line 52”

Strange I uploaded 20 odd images and they all reported to be under 2MB in size - 2 of the images didn’t upload, but all the others had no issues.

OK, is the PHP memory_limit variable in a php.ini file? If so where can I find that?

Appreciate the help as always.

Cheers
Chumby

yes. you can edit the php.ini file and look for it. It’s something like memory_limit

php.ini. file is usually in the root folder (public_html). If you don’t have one, you may be able to create one from your host’s c-panel.

Thanks Rod and Ben,

Was able to have a hunt in my CPanel and noticed under PHP Selector / Options there was the memory_limit option. I changed that to 256Mb and now all uploads working well.

Appreciate your help as always.

Cheers,
Chumby

1 Like