Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#25 2012-07-30 18:17:16

photonomad
Member
Registered: 2005-09-10
Posts: 290
Website

Re: esq_autoimageresize - Automatically resize uploaded images

Hi Cain-Mi, Thanks for your reply. Unfortunately, I updated my php.ini file and I still get a fatal error. I put copies of the php.ini (with the 128M memory limit) in every directory I could think of and it still returns a blank page with this error when uploading:

Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 15488 bytes) in /home2/photonom/public_html/staceyirvin/textpattern/lib/class.thumb.php on line 163

When I return and refresh the images tab, the image is uploaded, not resized and no thumbnail exists.

Offline

#26 2012-07-30 23:22:49

radneck
Plugin Author
Registered: 2005-07-03
Posts: 109

Re: esq_autoimageresize - Automatically resize uploaded images

Hi photonomad,

Sorry I should have thought about my answer more.

There is only one php.ini, and it normally sits in /etc/, which you probably don’t have access to unless you manage your own VPS. Its the main PHP config file, and is quite large.

The other way to make this change is in a .htacces file – don’t make any new ones just edit the one in the textpattern base directory – add a new line that contains php_value memory_limit 128M and let me know how you go.

Last edited by radneck (2012-07-30 23:25:04)

Offline

#27 2012-08-20 14:30:10

admi
Member
From: BY
Registered: 2007-12-10
Posts: 145
Website

Re: esq_autoimageresize - Automatically resize uploaded images

Thanks a lot. Just installed the plugin. It is saving my time.

Offline

#28 2012-08-21 14:48:13

photonomad
Member
Registered: 2005-09-10
Posts: 290
Website

Re: esq_autoimageresize - Automatically resize uploaded images

Thank you for your reply! Somehow I missed it until now. Sorry about that! I tried editing my .htaccess file, but that didn’t work and then my server (Bluehost) disabled that line because of security risks.

I talked to Bluehost tech support today and they assisted in raising all of the limits in my php.ini file that might help. Here are the key limits they changed/set (PHP version 5.2.17):
max_execution_time = 360 ; Maximum execution time of each script, in seconds
max_input_time = 360 ; Maximum amount of time each script may spend parsing request data
memory_limit = 640M ; Maximum amount of memory a script may consume (640MB)
upload_max_filesize = 100M ; Maximum allowed size for uploaded files

The php.ini file sits in the root of my directory and is used by all of my directories.

However, when I try to upload a large image (4 or 5 mb) in Textpattern, this Fatal Error always comes up:
Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 3872 bytes) in /home2/photonom/public_html/staceyirvin/textpattern/lib/class.thumb.php on line 163

Here is the code that throws the error in class.thumb.php (specifically line 163):

161 // read SRC
162 if ($this->_SRC['type'] == 1)	$this->_SRC['image'] = imagecreatefromgif($this->_SRC['file']);
163 elseif ($this->_SRC['type'] == 2)	$this->_SRC['image'] = imagecreatefromjpeg($this->_SRC['file']);
164 elseif ($this->_SRC['type'] == 3)	$this->_SRC['image'] = imagecreatefrompng($this->_SRC['file']);

The Bluehost tech people have really spent time on the phone with me trying to figure it out, but they can’t seem to find anything on their end that is causing the error. However, I realize that your plugin obviously works for other people on other servers. Any thoughts?

Offline

#29 2012-08-22 01:09:34

radneck
Plugin Author
Registered: 2005-07-03
Posts: 109

Re: esq_autoimageresize - Automatically resize uploaded images

Hi photonomad,

33554432 bytes is 32 megabytes, so regardless of the fact that they’ve set up PHP to be able to use up a large amount, it can’t seem to get more than 32MB. This would be because either Apache didn’t get restarted after they made the php.ini changes, or the shared server you’re on won’t allocate you more than 32MB RAM.

imagecreatefromjpeg is a PHP GD function, so unfortunately if it’s this step throwing errors, it’s not possible to, for example, rewrite it to use less memory.

Also, 4 or 5 megabytes is quite a large image, it is quite unusual to manipulate such large images online, except with a specialty service, which would definitely have a lot more memory that 32MB.

Last edited by radneck (2012-08-22 01:10:09)

Offline

#30 2012-08-22 16:19:37

photonomad
Member
Registered: 2005-09-10
Posts: 290
Website

Re: esq_autoimageresize - Automatically resize uploaded images

BIG UPDATE! Problem solved! After exhaustive support from the tech people at Bluehost yesterday and this morning, one of them found the culprit and it wasn’t the server, it was in the textpattern/lib/constants.php file.

line 63: define('EXTRA_MEMORY', '32M');

I changed the limit to 64M and now esq_autoimageresize is handling 5MB jpeg uploads without issue. :)

Offline

#31 2012-08-23 00:16:24

radneck
Plugin Author
Registered: 2005-07-03
Posts: 109

Re: esq_autoimageresize - Automatically resize uploaded images

Ah! Good job. Here’s the commit to adjust the memory, which is over 5 years old!
I guess I didn’t notice this error because it only tries to adjust the memory if the image is over 1024px wide or high, which I haven’t really come across.

The problem with it is that it doesn’t check if you’d already changed the memory to a higher value first, and just overrides it to 32MB regardless. This was fixed in commit 3607 which should be out in the next TXP release (4.4.2).

This really is a good discovery, I think quite a few people would have stumbled on this issue, and been quite confused as to why the script wasn’t getting more memory when they’d set it in php.ini or .htaccess.

Last edited by radneck (2015-11-04 07:39:18)

Offline

Board footer

Powered by FluxBB