Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#16 2011-03-29 12:00:50

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

Re: esq_autoimageresize - Automatically resize uploaded images

Righto Kev,

Firstly, I originally misunderstood the thumbnail issue when it was first stated, so apologies for that. I never used thumbnails so I never noticed the problem myself.
The problem stemmed from the fact that this plugin uses the txp thumbnail class to resize the images – the process went a little like this:

  1. Create a thumbnail of uploaded image, using the dimensions we want the resized image to be
  2. Copy the newly generated thumbnail over as the main image
  3. Delete the thumbnail
    Obviously during that process, any existing thumbnail gets wiped. It didn’t actually affect the automatic thumbnail generation that txp uses, but because the callbacks used by this plugin are processed after the thumbnails are generated, they just got wiped over, making it look like the automatic thumbnail generation failed silently.

I’ve updated the plugin to fix this issue. However I’m pretty busy at the moment, so I haven’t had a chance to test as extensively as I normally like to. Please report any bugs you encounter.

Your other request was pretty trivial to implement, you can find the code here (dump straight into the edit plugin window, preferably after upgrading to 1.03). Just edit the variables noted (lines 11 to 13). I left a sample width and height in there. Crop can either be 0 (false) or 1 (true).

Just for clarities sake:
For everyone (not just Kevin): this plugin has been updated.

Last edited by radneck (2015-11-04 07:40:44)

Offline

#17 2011-06-05 17:00:07

jayrope
Plugin Author
From: Berlin
Registered: 2006-07-06
Posts: 727
Website Mastodon

Re: esq_autoimageresize - Automatically resize uploaded images

Just to state it:
WORKS WELL WITH TXP 4.4.0.
Thanx a bunch!


A hole turned upside down is a dome, when there’s also gravity.

Offline

#18 2011-07-15 14:37:05

jayrope
Plugin Author
From: Berlin
Registered: 2006-07-06
Posts: 727
Website Mastodon

Re: esq_autoimageresize - Automatically resize uploaded images

Questions:

1. Is there a way to activate GD’s image resampling and control over GD’s quality setting within this plugin?
(I doubt it, as i couldn’t find anything in txpimage.php as well…)
2. Would it be possible to add the option of entering a default category automatically to the resized image, just to get around the bug in conjunction with lam_image_uploader ? Basically this coudl look like a radio button enabling “automatic category assign” [dropdown list of image categories].
3. I am using this in conjunction with bot_image_upload instead now. In irregular intervals, though, the resizing doesn’t take place. I have to save the image and reupload it then. I’ll have to nail down the exact conditions with a proper test case, in case you’d need this.

Thank you very much in advance.

Last edited by jayrope (2011-07-15 14:45:54)


A hole turned upside down is a dome, when there’s also gravity.

Offline

#19 2011-07-19 07:51:09

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

Re: esq_autoimageresize - Automatically resize uploaded images

Sorry for the late response. I’ve replied in-line below.

jayrope wrote:

1. Is there a way to activate GD’s image resampling and control over GD’s quality setting within this plugin?
(I doubt it, as i couldn’t find anything in txpimage.php as well…)

No sorry, I don’t think so. I haven’t really used GD much – this is the first time actually – so the extent of my knowledge of the extension is limited to what I could get from the txp_image.php.

2. Would it be possible to add the option of entering a default category automatically to the resized image, just to get around the bug in conjunction with lam_image_uploader ? Basically this coudl look like a radio button enabling “automatic category assign” [dropdown list of image categories].

I’d say yes, this should definitely be possible – but you may have to break out ied_plugin_composer and have a crack at coding that in yourself, as I currently don’t have time to work on this plugin I’m sorry.

3. I am using this in conjunction with bot_image_upload instead now. In irregular intervals, though, the resizing doesn’t take place. I have to save the image and reupload it then. I’ll have to nail down the exact conditions with a proper test case, in case you’d need this.

This sounds unusual, and if you’re able to provide a test-case I can reproduce I’ll try and get it fixed. I’m not sure if this is completely on the wrong path, but I have seen issues with some plugins on the write tab when the tab is loaded as the default tab (i.e. URL is /textpattern/ or /textpattern/index.php) instead of through clicking on the actual tab (i.e. URL is /textpattern/?event=article).

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

Offline

#20 2011-07-30 14:27:16

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

Re: esq_autoimageresize - Automatically resize uploaded images

I am using TXP 4.4.1 and just installed esq_autoimageresize. If I try to upload an image that is larger than the resize dimensions that are specified in the plugin options, the image does not upload. Instead, textpattern displays “No file was specified” in the upper left area of the page.

I am wondering if this is an error due to the image-related security upgrades in TXP 4.4.1?

Offline

#21 2011-08-02 13:26:30

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

Re: esq_autoimageresize - Automatically resize uploaded images

How large was the image (in MB, not pixels)? It may be that the file was bigger than what the PHP settings allow.
I doubt it has to do with the upgrades. Can you upload a normal sized image?

Offline

#22 2012-07-18 18:12:30

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

Re: esq_autoimageresize - Automatically resize uploaded images

It has been long time since my previous post about esq_autoimgeresize. The “no file was specified” problem seems to have worked itself out. However, I am now revisiting the plugin for use on two different sites. Both sites have a nice big 8MB upload limit. Big images are uploading fine, however they do not consistently resize with the plugin. I’ve tried a bunch of tests to see if I can find the culprit: I’ve turned all plugins off and had the same issues. Sometimes I update the plugin settings and the resize will work, other times this doesn’t have any effect. Sometimes I empty my browser cache or I turn plugins back on or change the plugin load order. Nothing seems to get it to work consitently. I’ll upload 4 big horizontal images in a row and all will resize, then I upload a big vertical image and it doesn’t resize and subsequent uploads (regardless of orientation) will fail to resize too. Any thoughts?

Last edited by photonomad (2012-07-18 21:55:34)

Offline

#23 2012-07-22 19:55:26

nabrown78
Member
From: Northampton, MA, USA
Registered: 2006-10-04
Posts: 294
Website

Re: esq_autoimageresize - Automatically resize uploaded images

This plugin looks perfect for a particular client’s site, but I’ve installed it and it doesn’t seem to be working. Some site details:

Textpattern version: 4.4.1 (r3575)
Last Update: 2012-07-11 02:31:03/2012-07-11 02:29:54
upload_tmp_dir: /localservices/phpupload
Temporary directory path: /services/webpages/j/a/jandonley.net/public/textpattern/tmp
Site URL: www.jandonley.net
PHP version: 5.2.17
Register globals: 1
GD Image Library: bundled (2.0.34 compatible); supported formats: GIF, JPG, PNG.

I don’t see any errors anywhere, and images upload fine; they simply do not resize. I am not using the per-category resizing, but even using that images aren’t resized.

EDIT: I was just experimenting around and at some point, I did see this error at the bottom of the images tab:

Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 1600 bytes) in /services6/webpages/util/j/a/jandonley.site.aplus.net/public/textpattern/lib/class.thumb.php on line 213

But now I can not reproduce it. The images I’ve been using a largish, but under 1MB

Last edited by nabrown78 (2012-07-22 20:03:29)

Offline

#24 2012-07-24 06:24:33

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

Re: esq_autoimageresize - Automatically resize uploaded images

Sorry for the late replay guys.

Both of these issues are without a doubt related to PHP memory, especially as Nora you saw it first hand.

If you have a large enough upload limit, which seems likely as the image does land, then it could only be the PHP memory.

The script will require varying amounts of memory, depending on how big the image is as well as how severe the resize is. I haven’t been able to work out a particular forumla, but Nora 33554432 bytes is only 32 MB, not a huge amount of ram.

Try setting memory_limit = 128M in your php.ini file, and seeing how you go.

As for browser side settings (clearing cache etc), these will have no affect, its purely what’s going on serverside. Other plugins shouldn’t have an affect either, unless they’re tapped into the same image upload/save hooks that esq_autoimageresize is.

Let me know how you go.

Offline

#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

Board footer

Powered by FluxBB