MyBB Community Forums

Full Version: Image Auto-Resizer 1.1.0
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6 7
(2021-12-29, 03:20 PM)HLFadmin Wrote: [ -> ]As a followup, I have upgraded production to 1.8.29, and am running  Auto-Resizer 1.04 successfully.

Great to hear.

(2021-12-29, 03:20 PM)HLFadmin Wrote: [ -> ]One problem is it still throws an error if the database says an attachment is there, but the file is not on the server.

Ah. That's due to accidentally skipping some error checking code on my part. Please see whether changing lines 318 and 319 of inc/plugins/auto_resizer.php as follows fixes the problem for you. From:

	$true_size = filesize($uploadspath_abs."/".$attachment['attachname']);
	if ($attachment['filesize'] != $true_size) {

To:
	$true_size = @filesize($uploadspath_abs."/".$attachment['attachname']);
	if ($true_size !== false && $attachment['filesize'] != $true_size) {

In other words: prepend filesize with an @ on the first line, and prepend a check for $true_size not being strictly identical to false to the conditional on the second line.
That change has stopped the error code in the instance it occurred.
Thank you for this plugin. It's a 5-star winner. Smile
Thanks for your very positive feedback, HLFadmin! Thanks to your testing, I've released version 1.0.5 of this plugin, which simply incorporates the changes I described above and which you have confirmed solved your problem:
  • Bugfix: when a file was missing in the filesystem, the corrective for the bug in v1.0.3 was causing errors to be generated. (An alternative to upgrading from v1.0.4 to v1.0.5 so as to fix this is to use the Find Orphaned Attachments functionality of the ACP to remove the database entries for any missing files).
I am trying to use this plugin but I am getting this error when I try to resize existing errors...

Quote:Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 12288 bytes) in /home/alpharomeo15/public_html/inc/plugins/auto_resizer.php on line 241

Any ideas on the cause and how can I get it to work?
It's likely that you've got an image that is tens of megabytes in size, and, in the course of the plugin loading it into memory so as to reorient it as necessary, prior to (potentially) resizing it, your PHP memory limit is being exceeded.

The first thing you could try (untested) is to insert, just prior to line #241 of inc/plugins/auto_resizer.php, this line:
				check_thumbnail_memory($imgsz[0], $imgsz[1], $imgsz[2], isset($imgsz['bits']) ? $imgsz['bits'] : null, isset($imgsz['channels']) ? $imgsz['channels'] : null);

If that doesn't work, then try bumping up your maximum PHP memory limit (Google should help you with how to do that). Note that some hosting providers don't allow it to be changed, or at least don't allow it to be changed above a value they set.
(2023-07-22, 11:30 AM)Laird Wrote: [ -> ]It's likely that you've got an image that is tens of megabytes in size, and, in the course of the plugin loading it into memory so as to reorient it as necessary, prior to (potentially) resizing it, your PHP memory limit is being exceeded.

The first thing you could try (untested) is to insert, just prior to line #241 of inc/plugins/auto_resizer.php, this line:
				check_thumbnail_memory($imgsz[0], $imgsz[1], $imgsz[2], isset($imgsz['bits']) ? $imgsz['bits'] : null, isset($imgsz['channels']) ? $imgsz['channels'] : null);

If that doesn't work, then try bumping up your maximum PHP memory limit (Google should help you with how to do that). Note that some hosting providers don't allow it to be changed, or at least don't allow it to be changed above a value they set.

I tried both methods but I am now getting this error when I try to run the resizer in recount & rebuild...

Quote: Fatal error: Uncaught Error: Call to undefined function check_thumbnail_memory() in /home/alpharomeo15/public_html/inc/plugins/auto_resizer.php:241 Stack trace: #0 /home/alpharomeo15/public_html/inc/plugins/auto_resizer.php(294): autorsz_fix_image_orientation('/home/alpharome...') #1 /home/alpharomeo15/public_html/inc/plugins/auto_resizer.php(186): autorsz_resize_file('202307/post_1_1...') #2 /home/alpharomeo15/public_html/inc/class_plugins.php(142): autorsz_hookin__admin_tools_recount_rebuild('') #3 /home/alpharomeo15/public_html/admin/modules/tools/recount_rebuild.php(19): pluginSystem->run_hooks(Array) #4 /home/alpharomeo15/public_html/admin/index.php(830): require('/home/alpharome...') #5 {main} thrown in /home/alpharomeo15/public_html/inc/plugins/auto_resizer.php on line 241
Maybe I didn't put the code in the right spot?

[attachment=46185]
(2023-07-24, 02:51 PM)RocketFoot Wrote: [ -> ]Maybe I didn't put the code in the right spot?

You did fine. It was my fault. Like I said, the code was untested, and it turns out it needs an extra line beforehand to make sure that the function is actually available to be called. Please insert this line just before the line I had you insert:

				require_once MYBB_ROOT.'inc/functions_image.php';
Any update on this, @RocketFoot? I'd like to incorporate a fix for your problem into the next release of this plugin, so it'd be helpful to know whether you solved your problem, and, if so, how.
(2023-08-06, 06:05 AM)Laird Wrote: [ -> ]Any update on this, @RocketFoot? I'd like to incorporate a fix for your problem into the next release of this plugin, so it'd be helpful to know whether you solved your problem, and, if so, how.

I'm sorry for the lack of a follow-up...I was unable to get it working.  I made the edit and also adjusted my server settings but I still got the error.  I ended up removing the plugin and resized the images with a @media class for post body images and it has been working good!
I'm assuming this will only resize images uploaded using attachment feature? It wont work for remote images, lets say from imgur.com?
Pages: 1 2 3 4 5 6 7