News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Automatic Attachment Rotation (and Resize)

Started by dougiefresh, March 04, 2016, 07:34:59 PM

Previous topic - Next topic

bmwplow

Great, thank you so much. Will take a look.

bmwplow

Hello,

Was able to fix the error at the top of the forum via the fix you mentioned (thank you for that).

Still not able to open the attachment settings section at all due to this error:

When loading the attachment settings section:

An Error Has Occurred!
syntax error, unexpected 'attachment_enableAutoRotateMod' (T_STRING), expecting ')'

Any ideas on that one?

I really appreciate the help, thank you.

GL700Wing

#442
Quote from: bmwplow on April 22, 2023, 10:31:04 PMWas able to fix the error at the top of the forum via the fix you mentioned (thank you for that).
Great!

QuoteStill not able to open the attachment settings section at all due to this error:

When loading the attachment settings section:

An Error Has Occurred!
syntax error, unexpected 'attachment_enableAutoRotateMod' (T_STRING), expecting ')'

Any ideas on that one?

I really appreciate the help, thank you.
Are you able to see if there is a corresponding message in the forum's error logs and post the details of the file and line number the error is being reported for?

BTW:  This mod installs and works as expected in a standard SMF 2.0.19 forum (ie, source code and theme) without causing the issues you've encountered so it seems to me that some sort of coding conflict has occurred between this version of this mod and another mod you are using. (I've confirmed this mod does not update/modify any of the NightBreeze theme files).

Were any errors reported with the uninstallation of v5.9 of this mod, the installation of v6.16 of this mod or any other mod you've installed/uninstallled? 

Also, what other mods do you have installed and what order were they installed in?
Life doesn't have to be perfect to be wonderful ...

Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

bmwplow

Been doing some more testing on my testing forum. I have uninstalled the few mods I had, including 5.9 which uninstalled cleanly without error. These only seem to show up after I try doing the newer version. Going to load a new vanilla install tomorrow to see how that works for me.

I seem to be getting three errors:

/index.php?action=admin;area=manageattachments;sa=attachments;decc298e9f=e9d4f5cd473ed6b679a625e0c69eee70

syntax error, unexpected 'attachment_enableAutoRotateMod' (T_STRING), expecting ')'
 
� Type of error: Undefined
�/index.php?action=admin;area=manageattachments;sa=attachments;decc298e9f=e9d4f5cd473ed6b679a625e0c69eee70

8: Undefined index: description

File: /Themes/default/Errors.template.php (generic_menu_dropdown_above sub template - eval?)
Line: 303


 

� Type of error: Undefined

/index.php?action=admin;area=manageattachments;sa=attachments;decc298e9f=e9d4f5cd473ed6b679a625e0c69eee70

8: Undefined index: title

File: /Themes/default/Errors.template.php (generic_menu_dropdown_above sub template - eval?)
Line: 291

These are the few mods I had. I believe they are were done in this order, although its been years since I loaded them originally.

1.   Automatic Attachment Rotation (and Resize)   5.9   
2.   Tapatalk SMF 2.0 Plugin   4.5.8   
3.   Simple Audio Video Embedder   7.0.1

5.9 was uninstalled and replaced with the newer version.

Sir Osis of Liver

Installed in 2.0.19, does not resize images.


static $default_formats = array(
'1' => 'gif',
'2' => 'jpeg',
'3' => 'png',
'6' => 'bmp',
'15' => 'wbmp'
,
// Automatic Attachment Rotation (and Resize) mod.
// Added support for 'webp' images.
'18' => 'webp',
);

require_once($sourcedir . '/Subs-Package.php');

// Begin Automatic Attachment Rotation (and Resize) mod.
//@ini_set('memory_limit', '90M');

global $modSettings;
$useImagick = $imageMemory = false;
if (!empty($modSettings['attachment_enableAutoRotateMod']))
{
require_once($sourcedir . '/Subs-AutoRotation.php');
$useImagick = class_exists('Imagick', false) && !empty($modSettings['attachment_use_imagick']);
$imageMemory = !empty($modSettings['attachment_memory_limit']);
}
// End Automatic Attachment Rotation (and Resize) mod.
$success = false;

// Get the image file, we have to work with something after all

Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

GL700Wing

Quote from: Sir Osis of Liver on May 05, 2023, 09:59:48 PMInstalled in 2.0.19, does not resize images.
static $default_formats = array(
'1' => 'gif',
'2' => 'jpeg',
'3' => 'png',
'6' => 'bmp',
'15' => 'wbmp'
,
// Automatic Attachment Rotation (and Resize) mod.
// Added support for 'webp' images.
'18' => 'webp',
);

require_once($sourcedir . '/Subs-Package.php');

// Begin Automatic Attachment Rotation (and Resize) mod.
//@ini_set('memory_limit', '90M');

global $modSettings;
$useImagick = $imageMemory = false;
if (!empty($modSettings['attachment_enableAutoRotateMod']))
{
require_once($sourcedir . '/Subs-AutoRotation.php');
$useImagick = class_exists('Imagick', false) && !empty($modSettings['attachment_use_imagick']);
$imageMemory = !empty($modSettings['attachment_memory_limit']);
}
// End Automatic Attachment Rotation (and Resize) mod.
$success = false;

// Get the image file, we have to work with something after all
All that block of code does is define some variables that are used further down for calling the 'resizeImage' function (which is where the actual image resizing is done).

I've been using the latest version of this mod (ie, v6.16) on all my forums without any issues (ie, images are always resized) for almost a year so I can't understand why you're having an issue.

What are the details (eg, dimensions and/or JPEG quality) of the images that are not being resized?

BTW: I've noticed that you have JPEG quality set to 100 and this can result in the file size of an uploaded image increasing if the GD converter is used (the iMagick converter usually creates a smaller file).
Life doesn't have to be perfect to be wonderful ...

Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

Sir Osis of Liver

I've used the mod on several forums, but it's not working on this one.
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

GL700Wing

Quote from: Sir Osis of Liver on May 05, 2023, 10:29:11 PMI've used the mod on several forums, but it's not working on this one.
OK - I thought it may be an issue for PNG files but I've just successfully tested resizing a PNG file that is 3082 X 2048 and 6.35Mb in size using both GD and iMagick.

Are you sure the file you're uploading is actually a PNG file and not just a file with the 'png' filename suffix? 

The reason I'm asking is that MIME checking is not done (only file name extensions are optionally checked) and I know that if a file with an image MIME that is not supported is uploaded it will be attached without any resizing being done.

Does this issue also occur with known JPG files?
Life doesn't have to be perfect to be wonderful ...

Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

Sir Osis of Liver

I have two versions of that image, one is 13.73mb png, other is 3.98mb jpg, same dims, neither is resized, no errors.  I've installed it on second forum, same result.
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

GL700Wing

Quote from: Sir Osis of Liver on May 05, 2023, 11:07:26 PMI have two versions of that image, one is 13.73mb png, other is 3.98mb jpg, same dims, neither is resized, no errors.  I've installed it on second forum, same result.
Interesting - are you able to give me a link so that I can download both files?
(You can send it to me via PM if you don't want to post it here)
Life doesn't have to be perfect to be wonderful ...

Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

Sir Osis of Liver

Tried different jpg, isn't resized.  I now have it installed on three different forums, same server.  Wondering if something changed when host moved my server to their new cloud platform few weeks ago.

Version Information:
Forum version: SMF 2.0.19 (more detailed)
Current SMF version: SMF 2.0.19
GD version: 2.3.3
Database Server: MariaDB
MySQL version: 10.6.12-MariaDB-cll-lve
PHP: 8.0.28
Server version: LiteSpeed
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Sir Osis of Liver

Just tried it on client forum where I installed it couple months ago, works fine.  Same host, different server, not on cloud platform.

Version Information:
Forum version: SMF 2.0.19 (more detailed)
Current SMF version: SMF 2.0.19
GD version: 2.3.3
Database Server: MariaDB
MySQL version: 10.3.38-MariaDB-cll-lve
PHP: 8.0.28
Server version: LiteSpeed
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Sir Osis of Liver

Ok, there's a difference between my forums (where it doesn't work) and client forum (where it does).  Client has 'Use Imagick' enabled, it's greyed out on my forums.
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

GL700Wing

Quote from: Sir Osis of Liver on May 05, 2023, 11:55:55 PMOk, there's a difference between my forums (where it doesn't work) and client forum (where it does).  Client has 'Use Imagick' enabled, it's greyed out on my forums.
I've successfully tested it with both GD and Imagick.

The 'iMagick' option is greyed out if the extension is not enabled in cPanel.
Life doesn't have to be perfect to be wonderful ...

Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

Sir Osis of Liver

Imagick and GD are both enabled in php 8, but mod is not seeing Imagick.
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Sir Osis of Liver

Host support enabled Imagick just before I found it, so it had been disabled.  Resize is working now.  Any idea why it doesn't work with GD?
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

GL700Wing

Quote from: Sir Osis of Liver on May 06, 2023, 12:16:12 AMHost support enabled Imagick just before I found it, so it had been disabled.  Resize is working now.  Any idea why it doesn't work with GD?
No idea re GD because I'm using the mod with same version of GD (ie, I don't have iMagick enabled) on all my production forums (which are all on different servers) and the mod works.

Wondering if GD is corrupted/incomplete on the server you're using ...
Life doesn't have to be perfect to be wonderful ...

Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

Sir Osis of Liver

Host support suggested that mod may not be compatible with newer version of GD.  Are you using 2.3.3?
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

GL700Wing

Quote from: Sir Osis of Liver on May 06, 2023, 10:58:58 PMHost support suggested that mod may not be compatible with newer version of GD.  Are you using 2.3.3?
Yes - I'm using the same version of the mod with GD 2.3.3 (ie, I don't have iMagick enabled) on all my production forums (which are all on different servers) and the mod works as expected.
Life doesn't have to be perfect to be wonderful ...

Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

GL700Wing

#459
I've just confirmed that this issue occurs with PHP 8.0 but not with PHP 7.4 - now just gotta work out why ...
You cannot view this attachment.


Edit:
Found out why - see PHP 8.0 : \GDImage object is used instead of resource type - and fortunately the fix looks easy to implement ...


Life doesn't have to be perfect to be wonderful ...

Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

Advertisement: