News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Automatic Attachment Rotation (and Resize)

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

Previous topic - Next topic

Rob Lightbody

Hi,

Returning to report that v5.9 has resolved all the issues we were having.

Thanks very much indeed.

- Rob

TourFL

Hello,

I migrated to the 5.9 version, with SMF 2.0.17, and the messages I previously had in the error logs are still there  :(
It seems it's only for users using "search" functionnality, so there is improvement, and much less occurences! But one search generates 12 errors, so it's adding up fast

http://www.500-126.com/index.php?action=search2
8: Undefined index: thumb_hash
File: /home/clients/XXX/web/Sources/Display.php
Line: 1762

http://www.500-126.com/index.php?action=search2
8: Undefined index: thumb_folder
File: /home/clients/XXX/web/Sources/Display.php
Line: 1762

http://www.500-126.com/index.php?action=search2
8: Undefined index: thumb_name
File: /home/clients/XXX/web/Sources/Display.php
Line: 1762


The code at this line, in my Display.php file:
1760: }
1761:   else
==>1762: $thumb_realname = getAttachmentFilename($attachment['thumb_name'], $attachment['id_thumb'], $attachment['thumb_folder'], false, $attachment['thumb_hash']);
1763:
1764: // Get timestamp for thumbnail image:
1765: $time = !empty($thumb_realname) && file_exists($thumb_realname) ? filemtime($thumb_realname) : false;


Any clue?
If you like Fiat 500 and derived models, the SMF forum I'm helping with: www.500-126.com

GL700Wing

Quote from: TourFL on January 22, 2020, 08:34:02 AM
Hello,

I migrated to the 5.9 version, with SMF 2.0.17, and the messages I previously had in the error logs are still there  :(
It seems it's only for users using "search" functionnality, so there is improvement, and much less occurences! But one search generates 12 errors, so it's adding up fast

...

Any clue?
I've had a look at this issue (which you've reported a few times) but I haven't been able to reproduce it and I have this mod installed on three different forums which each have between 120 and 145 other mods installed.

I suspect there may have been an issue with a previous installation/removal of either this mod or that another mod is causing the issue.  What happens if you do a search after removing this mod?

PS:  I'm going away for the next 4-5 days and won't be able to follow up until after I return.
Life doesn't have to be perfect to be wonderful ...

TourFL

Thanks for your help!
I tried desinstaling the mod. Performing a search doesn't generate any error without the mod installed.

And actually logs showed me that it's not only the search generating errors.
I don't understand where are those 3 indexes defined, and why it's not seen from that part of the code.

I have also a mod called "Inline Attachements" (from Spuds), used to display images or links within the message text. I'm not sure if it might get in conflict. I checked for an update on that one, but it looks like it's not maintained anymore. I Saw Dougiefresh did a similar mod, unfortunately it's not the same syntax, so I guess all my messages will be messed up if I use it  :-\
If you like Fiat 500 and derived models, the SMF forum I'm helping with: www.500-126.com

Capion

Thank You for at really great mod ;)

Could You make it handle the images in SMF gallery too?
*if it works, dont fix it*

Sir Osis of Liver

#245
If  anyone's still supporting this mod, per this topic there are a couple of problems:

1. - If topic includes a post with large attachment (7.3mb) it doesn't load, you get wsod.

2. - Does not uninstall cleanly.  Package manager flags three errors but misses a fourth.  This line is not removed from Display.php -



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



A following comment line is removed instead.  Result is all attachments do not load.

Running on crappy server in php 5.5.
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

GL700Wing

Quote from: Sir Osis of Liver on September 09, 2020, 12:45:07 PM
If  anyone's still supporting this mod, per this topic there are a couple of problems:

1. - If topic includes a post with large attachment (7.3mb) it doesn't load, you get wsod.

2. - Does not uninstall cleanly.  Package manager flags three errors but misses a fourth.  This line is not removed from Display.php -



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



A following comment line is removed instead.  Result is all attachments do not load.

Running on crappy server in php 5.5.

Thanks for the bug reports.

I encountered the same issue with large file sizes a few weeks ago so I'm currently working on an update for this mod - as a result of a change I've made I've been able to upload a file that was 15.8Mb and 9272x2552 pixels - so while I'm at it I'll fix the second issue.
Life doesn't have to be perfect to be wonderful ...

GL700Wing

Quote from: Sir Osis of Liver on September 09, 2020, 12:45:07 PM
2. - Does not uninstall cleanly.  Package manager flags three errors but misses a fourth.  This line is not removed from Display.php -



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



A following comment line is removed instead.  Result is all attachments do not load.

Running on crappy server in php 5.5.
I investigated this issue on a forum with the following specs: PHP : 5.5; SMF : 2.0.15; Mod version: 5.9; No other mods installed.

I installed/uninstalled version 5.9 of this mod multiple times and it always installed/uninstalled without any errors (and there are no error='ignore' statements for ./Sources/Display.php) and following uninstallation the files that were updated by mod were exactly the same as they were before the mod was installed. 

That said, the issue of the comment getting removed is a weird one - the comment is removed when the mod is installed and reinstated when the mod is uninstalled - because the search condition in the installer file is 'before' not 'replace' ...
<operation> <!-- line 1219 -->
<search positon="before"><![CDATA[// Some defaults that we need.]]></search>
<add><![CDATA[require_once($sourcedir . '/Subs-AutoRotation.php');

]]></add>
</operation>


I'll also reply to the topic you referred to.
Life doesn't have to be perfect to be wonderful ...

Sir Osis of Liver

He has ver 3.12, that may be the problem.  Do you know what causes wsod with large attachments?
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

GL700Wing

Quote from: Sir Osis of Liver on September 09, 2020, 10:06:21 PM
He has ver 3.12, that may be the problem.  Do you know what causes wsod with large attachments?
WSOD occurs when trying to rotate images with large dimensions (ie, width x height) because the server runs out of memory - large filesizes (eg, the size in Mb) are not really the issue ...

As per the information in this post - which also applies to images that need to be rotated - an image has to be decompressed into memory and each pixel sampled.

Although this can still happen with version 5.9 of the mod it is much less likely to occur if the Image Processing Memory Limit is installed. 

One of the changes I'm making in the next version of this mod (ie, 5.10) for images that need to be rotated and resized is to resize them first as this reduces the amount of memory subsequently needed for rotating them.
Life doesn't have to be perfect to be wonderful ...

Sir Osis of Liver

There have been other server problems with this host, but forum owner doesn't want to move.  He has multiple forums and a lot of other stuff in the account and prefers to stay there.  Am hesitant to install any more mods until php version is updated, but hasn't happened yet.  Thanks for looking into this.
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

GL700Wing

Quote from: GL700Wing on September 09, 2020, 10:53:36 PM
Quote from: Sir Osis of Liver on September 09, 2020, 10:06:21 PM
He has ver 3.12, that may be the problem.  Do you know what causes wsod with large attachments?
WSOD occurs when trying to rotate images with large dimensions (ie, width x height) because the server runs out of memory - large filesizes (eg, the size in Mb) are not really the issue ...
I've spent the last few hours testing version 5.9 of the mod with the Image Processing Memory Limit mod installed to get a better understanding of how much memory an image that needs to be rotated actually needs (and to work out an easy way to calculate it).

What I've worked out is that the approximate amount of PHP memory (accurate to within a few Mbs) needed to rotate a photo taken by a digital camera/mobile phone can be calculated as follows:
24-bit images: Height x Width / 194000
32-bit images: Height x Width / 145000

Real Example:
PHP needed 192Mb of memory to rotate the attached 24-bit JPEG photo with dimensions of ~7700 pixels x ~4818 pixels and a filesize of ~26Mb - setting the value for the 'Image Processing Memory Limit' to 192 enabled the photo to be successfully uploaded and rotated.  Lower memory values resulted in either a WSOD or an error message advising that the image had failed security checks.

After reducing the filesize to ~4Mb by compressing the JPEG image to 80% PHP still needed 192Mb of memory to rotate the photo because the dimensions were still the same.

On the forums I manage uploaded images are reduced to a maximum height/width of 1024 pixels (with a relative corresponding width/height) and by using the new version of this mod I am working on to resize the photo to 1024 pixels by 642 pixels before rotating it the amount of memory required to subsequently rotate the image was reduced to less than 4Mb!
Life doesn't have to be perfect to be wonderful ...

Sir Osis of Liver

Quote from: GL700Wing on September 10, 2020, 06:59:37 AM
resize the photo to 1024 pixels by 642 pixels before rotating it the amount of memory required to subsequently rotate the image was reduced to less than 4Mb!

That's what I was thinking, downsize the image then rotate.  Members uploading huge images from phones was a problem on one of my forums, so I've been using this mod to resize with good results.  Rotation hasn't been needed, but the tradgang forum is very active, he's got over 30,000 attachments, and many of them need to be rotated.  I've installed the resize mod I've been using, but a mod that does both would be better, provided it doesn't hit memory limits on a crappy server.
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

GL700Wing

#253
Quote from: Sir Osis of Liver on September 10, 2020, 04:53:09 PM
That's what I was thinking, downsize the image then rotate.  Members uploading huge images from phones was a problem on one of my forums, so I've been using this mod to resize with good results.
I also used to use the Resize Attached Images mod in conjunction with this mod before the resize feature was added but I'd still run into memory issues with images that also needed to be rotated.

QuoteRotation hasn't been needed, ...
I need rotation for photos taken using digital cameras/mobile phones - like the one I've attached ...

Quotebut the tradgang forum is very active, he's got over 30,000 attachments, and many of them need to be rotated.
This mod includes a batch resizing capability (ie, it can reduce image dimensions and also compress JPEG images) but it doesn't automatically rotate JPEG images.  Also, and because the EXIF orientation for JPEG images is lost when they are resized, images that have already been resized have to be rotated manually.

QuoteI've installed the resize mod I've been using, but a mod that does both would be better, provided it doesn't hit memory limits on a crappy server.
The next release of this mod - should be available within the next week or so - should work fine on a server with limited memory provided that for images that also need to be rotated (either automatically or manually) the image width/height dimensions used when resizing are set to a low enough values (eg, 1024 x 1024).





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

forumovod

Automatic Attachment Rotation (and Resize)
the mod indicates problems at installation in 2.1 RC3
Community of forum owners (сообщество владельцев форумов на любых движках) https://forumovod.ru

GL700Wing

Quote from: forumovod on September 28, 2020, 11:55:56 PM
Automatic Attachment Rotation (and Resize)
the mod indicates problems at installation in 2.1 RC3
As per the installation/compatibility notes this mod has not been verified to work with 2.1 RC3.
Life doesn't have to be perfect to be wonderful ...

forumovod

Quote from: GL700Wing on September 29, 2020, 01:24:42 AM
As per the installation/compatibility notes this mod has not been verified to work with 2.1 RC3.

I know about it.
But I wanted to warn the author of the mod that we need to release the next version of the mod  :D
Community of forum owners (сообщество владельцев форумов на любых движках) https://forumovod.ru

GL700Wing

Quote from: forumovod on September 29, 2020, 10:05:27 PM
Quote from: GL700Wing on September 29, 2020, 01:24:42 AM
As per the installation/compatibility notes this mod has not been verified to work with 2.1 RC3.

I know about it.
But I wanted to warn the author of the mod that we need to release the next version of the mod  :D
A few things to keep in mind about SMF 2.0 mods:
1.  Not all mods developed for SMF 2.0 are required for SMF 2.1 as some of them have already been incorporated into SMF 2.1;
2.  Some mod authors are waiting for the final version of SMF 21 to be released before they update/redevelop their SMF 2.0 mods; and
3.  For a variety of reasons, it is likely that some SMF 2.0 mods will not be updated/redeveloped for SMF 2.1.

I have four SMF 2.0.17 forums that each have between 70 and 140 mods installed and I realise that some of the mods may not be needed/updated/redeveloped for SMF 2.1 - I'll just have to wait and see what mods I still need and what mods are available when the time comes to upgrade to SMF 2.1 ...
Life doesn't have to be perfect to be wonderful ...

forumovod

Quote from: GL700Wing on September 30, 2020, 02:02:21 AM
2.  Some mod authors are waiting for the final version of SMF 21 to be released before they update/redevelop their SMF 2.0 mods; and
3.  For a variety of reasons, it is likely that some SMF 2.0 mods will not be updated/redeveloped for SMF 2.1.

no comment
Community of forum owners (сообщество владельцев форумов на любых движках) https://forumovod.ru

GL700Wing

Quote from: forumovod on September 28, 2020, 11:55:56 PM
the mod indicates problems at installation in 2.1 RC3

Quote from: forumovod on September 30, 2020, 08:06:47 PM

FYI (and just in case you can't work it out): 2.1 RC2 is not the same as 2.1 RC3
Life doesn't have to be perfect to be wonderful ...

Advertisement: