Simple Machines Community Forum

Customizing SMF => Modifications and Packages => Topic started by: dougiefresh on March 04, 2016, 07:34:59 PM

Title: Automatic Attachment Rotation (and Resize)
Post by: dougiefresh on March 04, 2016, 07:34:59 PM
Link to the mod (https://custom.simplemachines.org/index.php?mod=4087)




Automatic Attachment Rotation (and Resize)
For SMF 2.0 and SMF 2.1
v6.25


By Dougiefresh (https://www.simplemachines.org/community/index.php?action=profile;u=253913) and GL700Wing (https://www.simplemachines.org/community/index.php?action=profile;u=112942)
Link to Mod (https://custom.simplemachines.org/mods/index.php?mod=4087)



Introduction
This mod allows the automatic rotation and/or flipping of JPEG images but only if they contain the relevant EXIF information.

NOTE: SMF contains an option called Re-encode potentially dangerous image attachments, which is enabled by default. This re-encoding removes the orientation information from attachments (amongst other things), which means attachments uploaded prior to this mod being installed will not be able to rotated properly, as the EXIF information is missing from the re-encoded attachment file!!

IMPORTANT NOTE FOR SMF 2.0 In order to fully support the Post and PM Inline Attachments (https://custom.simplemachines.org/mods/index.php?mod=3770) mod you must install this mod after you install that mod!!
Also, if you subsequently need to uninstall the Post and PM Inline Attachments (https://custom.simplemachines.org/mods/index.php?mod=3770) mod you must uninstall this mod first.

IMPORTANT NOTES REGARDING GD AND IMAGICK IMAGE PROCESSING
For SMF 2.0:
o GD is used even if the iMagick extension is enabled in PHP unless this mod is enabled with the 'Use iMagick' setting also enabled.
o EXIF metadata will always be removed from a JPEG image that is resized/compressed even if the 'Remove EXIF data from JPEG images' option is disabled.

For SMF 2.1:
o GD is used if the iMagick extension is not enabled in PHP or if this mod is enabled with the 'Use iMagick' setting disabled.

Major change introduced in v6.20
o Added option to configure and check for allowed image MIME types.

Major changes introduced in v6.12
o Added support for official release of SMF 2.1.
o Removed support for SMF 2.1 RC4.

Major changes introduced in v6.10
o Support for SMF 2.1 RC4 (official release only - not GitHub releases).
o Support for ImageMagick/Imagick image processor.
o Added options for rotating images and thumbnails separately when modifying a message (and for Admins when browsing files via the Admin center).
o Added code to display a thumbnail-sized copy of each attached image (and a smaller version of the real thumbnail if it exists) when editing a message (and for Admins when browsing files via the Admin Center).

Major change introduced in v6.00
o - Support for SMF 2.0.18 and PHP 7.4.

Major change introduced in v5.0
o Option to automatically, manually or batch resize/reformat existing images using 'Attachment Settings' options (non-JPEG images will only be reformatted to JPEG if the Reformat non-JPEG images to JPEG option is enabled).

Major changes introduced in v4.0
o Option to enable/disable automatic image rotation.
o Code update to enable automatic image resizing/reformatting in posts (and PMs if the PM Attachments (https://custom.simplemachines.org/mods/index.php?mod=1974) mod is installed).

Post Screen Changes
Beside each image attachment a dropbox will be displayed listing the following rotation options for the Image/Thumbnail, Image Only and Thumbnail Only:
o No Change
o Rotate 90o Right
o Rotate 90o Left
o Rotate 180o
o Horizontal Flip
o Vertical Flip
o Horizontal Flip, Rotate 90o Right
o Vertical Flip, Rotate 90o Right


Automatic Processing of Existing Images
When a post is displayed, and if the Attachment Setting Automatically process existing images option is enabled, images in the post will be automatically rotated, reformatted and/or resized using the same Attachment Setting options (ie, Automatically rotate JPEG images, Reformat non-JPEG images to JPEG, JPEG quality and/or maximum width/height) that are applied to new image attachments in posts. In addition, if the Attachment Setting option Create backup of original image file when resizing is also enabled the original image file will be saved to the attachments directory with the extension '.rei'.
Note: Images posted by members who belong to a membergroup that has specific JPEG quality and/or maximum width/height values configured will be resized according to the values configured for that membergroup.


Manual Resizing of Existing Images
This feature, which can be accessed via Admin => Forum => Attachments and Avatars => Browse Files => Automatic Attachment Rotation (and Resize) - Resize, Rotate, and/or Reformat Existing Images, can be used to selectively resize, rotate and/or reformat existing images using the same Attachment Setting options (ie, Automatically rotate JPEG images, Reformat non-JPEG images to JPEG, JPEG quality and/or maximum width/height) that are applied to new image attachments in posts.
Note: Images posted by members who belong to a membergroup that has specific JPEG quality and/or maximum width/height values configured will NOT be resized.


Batch Rotate, Reformat and/or Resize Existing Images
This feature, which can be accessed via Administraton Center => Attachments and Avatars => File Maintenance => Automatic Attachment Rotation (and Resize) - Batch Resize, Rotate, and/or Reformat Existing Images, will resize, rotate and/or reformat ALL existing images using the options configure via Administration Center => Attachments and Avatars => Attachment Settings (ie, "Automatically rotate JPEG images"; "Reformat non-JPEG images to JPEG"; "JPEG quality"; "Maximum width of attached images"; and "Maximum height of attached images").

Note:: Images posted by members who belong to a membergroup that has specific JPEG quality and/or maximum width/height values configured will NOT be resized.

The forum should be configured as follows BEFORE commencing batch resizing:
o Administraton Center => Configuration => Server Settings => General => Enable Maintenance Mode - should be enabled.
o Administraton Center => Configuration => Security and Moderation => General => Disable administration security - should be disabled.
o Administraton Center => Forum => Posts and Topics => Topic Settings => Number of topics per page in the message index - should be configured to between 15 and 25 via (make a note of the current value).
o Administraton Center => Attachments and Avatars => Attachment Settings - configure the following settings: "Automatically rotate JPEG images"; "Reformat non-JPEG images to JPEG"; "JPEG quality"; "Maximum width of attached images"; and "Maximum height of attached images".
o Administraton Center => Attachments and Avatars => File Maintenance => Attachment Integrity Check - should be run and issues corrected.

Important notes for batch resizing:
o JPEG images will only be rotated if the "Automatically rotate JPEG images" option is enabled AND if they contain the relevant orientation metadata.
o Non-JPEG images will only be reformatted to JPEG if the "Reformat non-JPEG images to JPEG" option is enabled.
o The existing 'attachments' database table will be copied to 'attachmentsPreREI' database table. **
o If the image backup option is enabled original image files are saved to the 'attachmentsPreREI' directory/folder. **
o The timestamp for resized image file is set to match timestamp of original image file.
o Batch processing progress information is displayed and updated.
o The results of the batch resizing process will be displayed on completion and also written to the forum error log file.

** The 'attachmentsPreREI' database table and directory/folder can be removed after checks have been done to confirm successful resizing - this will free up additional disk space on the server.

The forum should be configured as follows AFTER batch resizing has finished:
o Administraton Center => Configuration => Security and Moderation => General => Disable administration security - should be enabled.
o Administraton Center => Configuration => Server Settings => General => Enable Maintenance Mode - should be disabled.
o Administraton Center => Forum => Posts and Topics => Topic Settings => Number of topics per page in the message index - should be configured to previous value.


Admin Changes
In Administraton Center => Attachments and Avatars:
o Browse Files: There is a new column (and associated button) for rotating/flipping images - the options for rotating/flipping images are only shown for image attachments. There is also a new horizontal tab labelled 'Resize Existing Images' that can be used for manually resizing/reformatting existing images.
o Attachment Settings: Options to enable/disable the mod, configure a specific memory limit for image rotation/resizing, configure automatic image rotation and automatic resizing of existing images, enable/disable reformatting/resizing, option to reformat non-JPEG images to JPEG, enable removal of EXIF metadata from JPEG images, and options to set JPEG quality, and maximum width/height values for attached images. Also option to configure different JPEG quality, and maximum width/height values for some membergroups and to enable/disable this feature.
- **File Maintenance**: There is a new section for *Batch Resize Existing Images*. There is also a new section for *Reset Orientation Flag*.
o File Maintenance: There is a new section for Batch Resize, Rotate, and/or Reformat. There is also a new section for Reset Orientation Flag.

Compatibility Notes
This mod was tested on SMF 2.0.17 but should work on SMF 2.0 and up.
This mod is only compatible with the official release of SMF 2.1 RC4 (ie, not GitHub releases).
SMF 1.x is not and will not be supported.

For SMF 2.0 - These mods (not required) must be installed before this mod:
o Post and PM Inline Attachments (https://custom.simplemachines.org/mods/index.php?mod=3770)
o Improved Attachment Error Handling (https://custom.simplemachines.org/mods/index.php?mod=3255)

For SMF 2.0 - The following mod must be uninstalled before installing this mod:
o Resize Attachment Images (https://custom.simplemachines.org/mods/index.php?mod=2206)

For SMF 2.0 - The following mod is no longer required (additional memory for processing images can now be configured within this mod) and should be uninstalled:
o Image Processing Memory Limit (https://custom.simplemachines.org/mods/index.php?mod=4111)

Translators
o Dutch: @rjen (https://www.simplemachines.org/community/index.php?action=profile;u=287786)
o Spanish Latin: RockLee (https://www.simplemachines.org/community/index.php?action=profile;u=322597)

Special Credit
This mod relies on the phpExifRW (https://www.phpclasses.org/package/1042-PHP-EXIF-information-reader-and-writer.html) class, which is licensed under the GNU Lesser General Public License (https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html), in order to read the EXIF information from image files. This class makes the requirement of having EXIF support built-in, which some servers do not have, not important to the task of successfully pulling the orientation out of the image file. The exifReader.inc file was renamed to Class-exifReader.php in order to name the file in accordance with the naming convention of SMF and included in this mod.

Test images with EXIF orientation values embedded in them are available at Galloway.me.uk (https://www.galloway.me.uk/2012/01/uiimageorientation-exif-orientation-sample-images/), at the Image Orientation (https://www.elkarte.net/community/index.php?topic=2509.0) thread over at the ElkArte forum, and on GitHub - Recurser (https://github.com/recurser/exif-orientation-examples).

License
QuoteCopyright (c) 2016-2020, Douglas Orend, 2019-2024 Kathy Leslie
All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer; and
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Title: Re: Automatic Attachment Rotation
Post by: dougiefresh on March 13, 2016, 08:30:35 PM
Bug report and response to said bug report:
Quote from: dougiefresh on March 13, 2016, 08:26:16 PM
Quote from: dan4ever on March 11, 2016, 03:36:39 PM
@Dougiefresh

Your mod did not turn the tumbnail in my forum!!

/Dan
I read this statement again just now and I think I understand what is going on.  My mod only deals with rotating NEW attachments, pre-existing attachments are not touched....  If you are looking for functionality to deal with existing attachments, then I can add that into the mod as well.  However, such image processing is quite intensive and possibly time consuming for forums with a large number of attachments.....

Rereading the mod description, it also sounds like I need to clarify the purpose of the mod.....  ???

I would also advise you to post problems regarding specific mods into the support thread of that mod, which in this case is located here (http://www.simplemachines.org/community/index.php?topic=544111.0).....  It is by chance that I can across this particular bug report, and I don't look everywhere for threads regarding my 51 approved mods....  O:) :P

I've quoted these messages and placed them in the right thread for you, to make it easier for me to locate...  O:) :P
Title: Re: Automatic Attachment Rotation
Post by: FrizzleFried on March 14, 2016, 05:59:17 PM
Not working... maybe the mod doesn't work with inline attachment mod?

Title: Re: Automatic Attachment Rotation
Post by: dougiefresh on March 14, 2016, 06:04:17 PM
@Everybody: Regarding bug report two posts ago, I am attempting to rewrite the mod so that it also works for existing attachments.  Version 1.0 only works for NEW attachments (at least it worked during my testing....)

Quote from: FrizzleFried on March 14, 2016, 05:59:17 PM
Not working... maybe the mod doesn't work with inline attachment mod?
Honestly, I don't know if it will work with the inline attachment mod.  Hasn't been tested....
Title: Re: Automatic Attachment Rotation
Post by: FrizzleFried on March 14, 2016, 06:39:47 PM
I assume I don't need to turn anything on?

How I am testing is that I am uploading an image that shows rotated on my digital camera... it also shows rotated (vertical orientation) in windows explorer... but when I upload it it appears horizontal (should be vertical).   It's remaining horizontal... I've tried both having the image appear "in-line" as well as a standard upload with no in-line adjustments made... and both show up horizontal.

Title: Re: Automatic Attachment Rotation
Post by: dougiefresh on March 15, 2016, 07:28:39 PM
Uploaded v1.1 - March 14th, 2016
o Fixed several errors within the image_rotate_flip function.
o Added code to rotate/flip attachments upon download if they haven't been processed yet.
o Added code to rotate/flip attachments upon displaying topics if they haven't been processed yet.
o Branched image_rotate_flip function as AutoRotation_Process into Subs-AutoRotation.php file.
o Seperated SMF 2.0.x and SMF 2.1 install branches.




@FrizzleFried and dan4ever: Hopefully this update takes care of the problems you experienced in version 1.0....  Please note while the mod will attempt to fix the orientation on pre-existing attachments, the orientation information may already be removed due to forum processing of the image attachment prior to this mod's installation....
Title: Re: Automatic Attachment Rotation
Post by: dan4ever on March 20, 2016, 08:43:10 PM
No, still not working.
And I got alot of this error:

Quote
http://www.guldforum.se/forum/index.php?topic=3302.msg29328 (http://www.guldforum.se/forum/index.php?topic=3302.msg29328)
The database value you're trying to insert does not exist: width
Function: AutoRotation_Update
Fil: /storage/content/******/guldforum.se/public_html/forum/Sources/Subs-AutoRotation.php
Rad: 207



Quote from: dougiefresh on March 13, 2016, 08:26:16 PM
If you are looking for functionality to deal with existing attachments, then I can add that into the mod as well. 
YES, PLEASE!!!!!!!

/Dan
Title: Re: Automatic Attachment Rotation
Post by: dougiefresh on March 21, 2016, 07:12:41 PM
Quote from: dan4ever on March 20, 2016, 08:43:10 PM
No, still not working.
And I got alot of this error:

Quote
http://www.guldforum.se/forum/index.php?topic=3302.msg29328 (http://www.guldforum.se/forum/index.php?topic=3302.msg29328)
The database value you're trying to insert does not exist: width
Function: AutoRotation_Update
Fil: /storage/content/******/guldforum.se/public_html/forum/Sources/Subs-AutoRotation.php
Rad: 207
Damn, that looks familiar.....  I thought I took care of that error message...  (Big sigh)  Let me look into it again....

Quote from: dan4ever on March 20, 2016, 08:43:10 PM
Quote from: dougiefresh on March 13, 2016, 08:26:16 PM
If you are looking for functionality to deal with existing attachments, then I can add that into the mod as well. 
YES, PLEASE!!!!!!!
I've attempted to add functionality to deal with existing attachments in version 1.1.  It seems that SMF's re-encoding process strips out the EXIF information from the images, so it CAN'T automatically rotate and/or flip the image(s) accordingly.....  So I'm at a loss on how to proceed with those instances....

I guess I could add something in the Profile -> Show Posts -> Attachments screen....  I just don't know what at this moment....
Title: Re: Automatic Attachment Rotation
Post by: dan4ever on March 22, 2016, 09:29:28 AM
Quote from: dougiefresh on March 21, 2016, 07:12:41 PM
Quote from: dan4ever on March 20, 2016, 08:43:10 PM
No, still not working.
And I got alot of this error:

Quote
http://www.guldforum.se/forum/index.php?topic=3302.msg29328 (http://www.guldforum.se/forum/index.php?topic=3302.msg29328)
The database value you're trying to insert does not exist: width
Function: AutoRotation_Update
Fil: /storage/content/******/guldforum.se/public_html/forum/Sources/Subs-AutoRotation.php
Rad: 207
Damn, that looks familiar.....  I thought I took care of that error message...  (Big sigh)  Let me look into it again....

Quote from: dan4ever on March 20, 2016, 08:43:10 PM
Quote from: dougiefresh on March 13, 2016, 08:26:16 PM
If you are looking for functionality to deal with existing attachments, then I can add that into the mod as well. 
YES, PLEASE!!!!!!!
I've attempted to add functionality to deal with existing attachments in version 1.1.  It seems that SMF's re-encoding process strips out the EXIF information from the images, so it CAN'T automatically rotate and/or flip the image(s) accordingly.....  So I'm at a loss on how to proceed with those instances....

I guess I could add something in the Profile -> Show Posts -> Attachments screen....  I just don't know what at this moment....

Just an arrow to turn and save
Title: Re: Automatic Attachment Rotation
Post by: dougiefresh on March 22, 2016, 06:47:07 PM
Quote from: dan4ever on March 22, 2016, 09:29:28 AM
Quote from: dougiefresh on March 21, 2016, 07:12:41 PM
I guess I could add something in the Profile -> Show Posts -> Attachments screen....  I just don't know what at this moment....
Just an arrow to turn and save
Where?  On the attachment screen or on the post screen?
Title: Re: Automatic Attachment Rotation
Post by: dan4ever on March 24, 2016, 05:29:48 AM
Quote from: dougiefresh on March 22, 2016, 06:47:07 PM
Quote from: dan4ever on March 22, 2016, 09:29:28 AM
Quote from: dougiefresh on March 21, 2016, 07:12:41 PM
I guess I could add something in the Profile -> Show Posts -> Attachments screen....  I just don't know what at this moment....
Just an arrow to turn and save
Where?  On the attachment screen or on the post screen?


The best I think is on the post screen.
For the Admin, moderator and the member how post it. Not for everybody!!!


/Dan
Title: Re: Automatic Attachment Rotation
Post by: dougiefresh on March 24, 2016, 08:50:02 PM
Quote from: dan4ever on March 24, 2016, 05:29:48 AM
Quote from: dougiefresh on March 22, 2016, 06:47:07 PM
Quote from: dan4ever on March 22, 2016, 09:29:28 AM
Quote from: dougiefresh on March 21, 2016, 07:12:41 PM
I guess I could add something in the Profile -> Show Posts -> Attachments screen....  I just don't know what at this moment....
Just an arrow to turn and save
Where?  On the attachment screen or on the post screen?
The best I think is on the post screen.
For the Admin, moderator and the member how post it. Not for everybody!!!
Do we have enough quotes here?  :P  I'll put it on the attachment list line, since it'd be easier for me to code around a known number of attachments than a variable number (due to adding additional attachments, etc).  Yeah, I know it'd mean that you have to upload, then see if the attachment is rotated correctly, but.....  I guess it'd be better than nothing (which is what SMF has right now)....

Quote from: dan4ever on March 24, 2016, 05:29:48 AM
For the Admin, moderator and the member how post it. Not for everybody!!!
Duh....  :P
Title: Re: Automatic Attachment Rotation
Post by: dan4ever on March 24, 2016, 08:56:18 PM
OK
Title: Re: Automatic Attachment Rotation
Post by: dan4ever on March 25, 2016, 06:21:54 AM
Another idé...


Why not make this: in Admin -> Forum -> Attachments /(and)/ Thumbnails
Make an small preview of the picture on every line and ability to change/turn it.


/Dan 
Title: Re: Automatic Attachment Rotation
Post by: dougiefresh on March 25, 2016, 08:18:54 AM
Was thinking about doing something similar at the Profile -> Show Posts -> Attachments screen.....
Title: Re: Automatic Attachment Rotation
Post by: dougiefresh on March 25, 2016, 05:56:23 PM
Uploaded v1.2 - March 25th, 2016
o Fixed function calls in Subs-Graphics.php so that correct parameters are used.
o Added replacement "imagerotate" function for PHP < 4.3.  Unlikely to be needed, but whatever...




:o Whoops.... O:) I finally figured out why my tests with images having a non-zero orientation were spastic....  The parameters of the function being called were half wrong...  Fixed that and the pictures are rotated correctly....  Verison 1.2 contains the updated XML ops and PHP files....

Quote from: dan4ever on March 20, 2016, 08:43:10 PM
No, still not working.
And I got alot of this error:

Quote
http://www.guldforum.se/forum/index.php?topic=3302.msg29328 (http://www.guldforum.se/forum/index.php?topic=3302.msg29328)
The database value you're trying to insert does not exist: width
Function: AutoRotation_Update
Fil: /storage/content/******/guldforum.se/public_html/forum/Sources/Subs-AutoRotation.php
Rad: 207
Can you tell me if the error message still occurs?  I haven't gotten this error message on my localhost forum.....
Title: Re: Automatic Attachment Rotation
Post by: dan4ever on May 23, 2016, 07:10:10 AM
Hi, again


Have your latest update installed but the pic are still 45% wrong.


/Dan
Title: Re: Automatic Attachment Rotation
Post by: dan4ever on June 06, 2016, 07:12:13 PM
Quote from: dougiefresh on March 13, 2016, 08:30:35 PM

Can you tell me if the error message still occurs?  I haven't gotten this error message on my localhost forum.....

No more :)

Thanks!!!!

Quote from: dan4ever on March 25, 2016, 06:21:54 AM
Another idé...


Why not make this: in Admin -> Forum -> Attachments /(and)/ Thumbnails
Make an small preview of the picture on every line and ability to change/turn it.


/Dan 
This would be nice, and maybe to work throu al the tumbnails/attachment and change them.

/Dan
Title: Re: Automatic Attachment Rotation
Post by: -Rock Lee- on June 07, 2016, 12:00:17 PM
Very good @dougiefresh I see now modified afternoon I looked closer :)


Regards!
Title: Re: Automatic Attachment Rotation
Post by: KungFuJoe on June 30, 2016, 05:37:47 PM
Hello...tried installing your mod, but get this Database Error at the bottom of any topic I enter:

Unknown column 'thumb.proper_rotation' in 'field list'
File: /home2/yandc/public_html/test.#####.net/Sources/Display.php

I'm running 2.0.11

I do have the resize attachments mod.
Title: Re: Automatic Attachment Rotation
Post by: dan4ever on July 06, 2016, 12:59:48 PM
Quote from: dan4ever on May 23, 2016, 07:10:10 AM
Hi, again


Have your latest update installed but the pic are still 45% wrong.


/Dan


The problem is still here...


/Dan
Title: Re: Automatic Attachment Rotation
Post by: dougiefresh on July 12, 2016, 07:07:09 PM
I'm trying to write the modification to the admin area where you can change the rotation of individual attachments manually....  Haven't forgotten about ya, just REALLY busy with work and a few other things.  :(
Title: Re: Automatic Attachment Rotation
Post by: dan4ever on July 13, 2016, 05:58:08 AM
Thanx!!!!!
Title: Re: Automatic Attachment Rotation
Post by: dougiefresh on August 20, 2016, 06:16:47 PM
About a month ago, I've lost my job and have been severely depressed.  I need some help, so if you want to help, please do so!

I've uploaded this mod to GitHub here: https://github.com/douglasorend/Automatic_Attachment_Rotation
Title: Re: Automatic Attachment Rotation
Post by: dougiefresh on September 15, 2016, 08:01:31 PM
Okay, I've started writing the stuff to manually rotate the images.  Attached is the current "mock-up" of the attachment screen...  Keep in mind that it is not set in stone yet, but the implementation doing it this way seems pretty straight forward.  Tell me what y'all think about this!  Thanks!
Title: Re: Automatic Attachment Rotation
Post by: dougiefresh on September 17, 2016, 09:34:32 PM
Uploaded v2.0 - September 17th, 2016
o Rewrote image processing function to work with built-in imagerotate and imageflip.
o Added several missing database query close statements.
o Added Admin changes to manually change the orientation of attachments.
Title: Re: Automatic Attachment Rotation
Post by: KungFuJoe on September 20, 2016, 12:54:18 PM
Can someone assist with the issue I posted about earlier?  I really really want to try out this mod since many of my users post pic attachments and they always come out the wrong way.

Thanks!
Title: Re: Automatic Attachment Rotation
Post by: dougiefresh on September 20, 2016, 04:16:12 PM
Uploaded v2.1 - September 20th, 2016
o Fixed unknown column error in Display.php that occurs when thumbnails are disabled.




@kungfujoe:  Whoops!!  I didn't realize I missed a bug report!  I'm pretty sure it's been fixed for this version!!  Thank you for bringing it up again!
Title: Re: Automatic Attachment Rotation
Post by: KungFuJoe on September 20, 2016, 06:18:45 PM
Quote from: dougiefresh on September 20, 2016, 04:16:12 PM
Uploaded v2.1 - September 20th, 2016
o Fixed unknown column error in Display.php that occurs when thumbnails are disabled.




@kungfujoe:  Whoops!!  I didn't realize I missed a bug report!  I'm pretty sure it's been fixed for this version!!  Thank you for bringing it up again!

Thanks for looking into this.  I uninstall 2.0 and installed 2.1 but now I get the following:

Parse error: syntax error, unexpected '(' in /home2/yandc/public_html/test.xxxxx.net/Sources/Subs-AutoRotation.php on line 193
Title: Re: Automatic Attachment Rotation
Post by: KungFuJoe on September 20, 2016, 06:30:18 PM
I'm I'm definitely not a programmer but I think it was just an extra set of parenthesis around this part of code:

($row['thumb_rotation'])

Do you see the same on your end?  When I remove them, it seems to work.  But just want to make sure I'm not screwing something up.
Title: Re: Automatic Attachment Rotation
Post by: dougiefresh on September 20, 2016, 06:44:44 PM
Uploaded v2.2 - September 20th, 2016
o Fixed syntax error found in Subs-AutoRotation.php.  Thanks, kungfujoe (http://www.simplemachines.org/community/index.php?action=profile;u=387324)!



Quote from: kungfujoe on September 20, 2016, 06:30:18 PM
I'm I'm definitely not a programmer but I think it was just an extra set of parenthesis around this part of code:

($row['thumb_rotation'])

Do you see the same on your end?  When I remove them, it seems to work.  But just want to make sure I'm not screwing something up.
@kungfujoe:  Yeah, I looked at the code real closely and saw that.  I can't believe I missed that....   Thanks for reporting the bug!
Title: Re: Automatic Attachment Rotation
Post by: KungFuJoe on September 20, 2016, 06:51:54 PM
Ok...I'm able to install the mod successfully.

However, it doesn't appear to be rotating images at all.  Could it be that I'm missing the phpExifRW class in PHP?

I see the option to rotate images in the Admin section, but I don't have any thumbnails for my images so it's difficult to know which way to rotate the images that are uploaded.
Title: Re: Automatic Attachment Rotation
Post by: KungFuJoe on September 20, 2016, 06:55:06 PM
Ok...I can simply click on the image name and it will bring up a pop up window with the image so I can work off that.

However, when I try to rotate an image, I get the following:

Fatal error: Call to undefined function AutoRotation_Rotate() in /home2/yandc/public_html/test.xxxxx.net/Sources/ManageAttachments.php on line 157
Title: Re: Automatic Attachment Rotation
Post by: dougiefresh on September 20, 2016, 07:24:03 PM
Revised v2.2 - September 20th, 2016
o Fixed syntax error found in Subs-AutoRotation.php.  Thanks, kungfujoe (http://www.simplemachines.org/community/index.php?action=profile;u=387324)!
o Fixed issue in the attachment screen, where attachment IDs were not being sent correctly.
o Fixed undefined index error in Subs-AutoRotation.php.
o Added forgotten package instruction to run add_remove_hooks.php during package operations.




@Everybody:  Since nobody downloaded the original v2.2, I've fixed a few issues within it....

Quote from: kungfujoe on September 20, 2016, 06:51:54 PM
However, it doesn't appear to be rotating images at all.  Could it be that I'm missing the phpExifRW class in PHP?
No, that class is contained in Class-exifReader.php and is loaded by Subs-AutoRotation.php only if the needed EXIF function aren't available.  Once you rotate an image in the admin panel, you will have to force a refresh (CTRL-F5) on the image in order to see the result.
Title: Re: Automatic Attachment Rotation
Post by: KungFuJoe on September 21, 2016, 12:54:47 AM
Thanks for continuing to work on this.

One typo I found is that when you choose to rotate an image in the Admin section, it prompts you if you want to REMOVE the image.  It rotates it fine...but the text is a bit misleading.  I'm sure it's an easy fix...but just FYI.
Title: Re: Automatic Attachment Rotation
Post by: KungFuJoe on September 21, 2016, 12:56:23 AM
Ok...so now the rotate function is working.

Couple questions.

Any photo I take with my iPhone in Portrait mode is turned to the left sideways.  Is this supposed to be happening or should the exif data be telling the mod how to position the picture upright?  The pic is position correctly when I look at it in any viewer in Windows/MacOS

Are users able to rotate their own images or can it only be done from within the admin console?
Title: Re: Automatic Attachment Rotation
Post by: dougiefresh on September 21, 2016, 11:42:46 PM
Quote from: kungfujoe on September 21, 2016, 12:56:23 AM
Ok...so now the rotate function is working.
Good to hear!

Quote from: kungfujoe on September 21, 2016, 12:56:23 AM
Any photo I take with my iPhone in Portrait mode is turned to the left sideways.  Is this supposed to be happening or should the exif data be telling the mod how to position the picture upright?  The pic is position correctly when I look at it in any viewer in Windows/MacOS
Yes, the EXIF information tells the mod how to rotate and/or flip the image so that it is viewed correctly.  There are several reasons why this might happen.  First, the EXIF information itself is incorrect (can't fix).  Second, the mod is reading the EXIF information incorrectly (can fix).  Third, the mod is rotating the image incorrectly (can fix).  Fourth, there is no EXIF information in the image (can't fix).

Can you attach the ORIGINAL image in question to a post or send by PM?  I need to examine and experiment with the image....

Quote from: kungfujoe on September 21, 2016, 12:56:23 AM
Are users able to rotate their own images or can it only be done from within the admin console?
Currently, it can only be done within the admin console.  I'll add some more stuff so that regular users can rotate their own images.....
Title: Re: Automatic Attachment Rotation
Post by: KungFuJoe on September 22, 2016, 02:53:00 PM
If I attach the image here won't this forum just strip out the EXIF information?

Perhaps I could email you?
Title: Re: Automatic Attachment Rotation
Post by: dougiefresh on September 22, 2016, 04:53:32 PM
Quote from: kungfujoe on September 22, 2016, 02:53:00 PM
If I attach the image here won't this forum just strip out the EXIF information?

Perhaps I could email you?
You are right, it might strip out the EXIF information.  I'll PM you with my email address.

EDIT: I did some testing using images from GitHub (https://github.com/recurser/exif-orientation-examples) on two different platforms: PHP 5.7 (which has the imagerotate and imageflip functions built-in), as well as PHP 5.3.9 (which do not). Both rotate and flip the images correctly, so I don't think it's the mod....

Hmmmm....  I didn't think about the forum itself stripping out the EXIF information....  I'll further look into this.
Title: Re: Automatic Attachment Rotation
Post by: dougiefresh on September 22, 2016, 06:57:13 PM
@kungfujoe: I got your picture.  The EXIF information is there and appears correct.  However, my localhost SMF install won't allow me to attach it to a post....  Hmmmm.

EDIT:  The Simple Machines Forum does, though....  I uninstalled the mod from my localhost, then tried again to attach it.  Still failed, so clearly this particular issue isn't a mod issue.  However, I can't test it if I can't upload it to my localhost server....   :o
Title: Re: Automatic Attachment Rotation
Post by: dougiefresh on September 25, 2016, 10:37:23 PM
UPDATE:  Sorry about the delay in responding.  It took some work, along with a considerable amount of fiddling with the settings of my Apache/PHP/MySQL server that I was using in order to get my localhost forum to upload the image.  Once I did, the forum correctly rotated and/or flipped the image so that it was upright....
Title: Re: Automatic Attachment Rotation
Post by: dan4ever on September 26, 2016, 08:51:55 AM
Good work!!!!


But I have "Highslide Image Viewer[/size][size=78%]" installed and the big picture that will come up when I click the pic is not turned.[/size]
[/size]Probably incompatibly  whith yours mod.[size=78%]
[/size][size=78%]But I really [/size][size=78%][/size]want the both och if you can include that too !!!!  ????[size=78%]


[/size][size=78%]/Dan  [/size][size=78%]
Title: Re: Automatic Attachment Rotation
Post by: dougiefresh on September 26, 2016, 09:39:12 AM
Uploaded v2.3 - September 26th, 2016
o Added code to include timestamps on attachment URLs to circumvent browser caching.



Quote from: dan4ever on September 26, 2016, 08:51:55 AM
But I have "Highslide Image Viewer" installed and the big picture that will come up when I click the pic is not turned.
Probably incompatibly  whith yours mod.
But I really want the both och if you can include that too !!!!  ????

Dan
I fixed the mod a few days so that the attachment URLs are modified with the timestamp, just to circumvent the browser caching crap that is built into SMF....  Once an image is turned, it should show up using Highslide Image Viewer as turned.

:o Btw, what's with all the extra tags?  Makes your post incredibly difficult to read....  Anyway, I removed the extra tags, just so it's readable in quotes....  O:)
Title: Re: Automatic Attachment Rotation
Post by: KungFuJoe on September 26, 2016, 04:05:47 PM
Quote from: dougiefresh on September 25, 2016, 10:37:23 PM
UPDATE:  Sorry about the delay in responding.  It took some work, along with a considerable amount of fiddling with the settings of my Apache/PHP/MySQL server that I was using in order to get my localhost forum to upload the image.  Once I did, the forum correctly rotated and/or flipped the image so that it was upright....

Hmmm...the pic doesn't rotate automatically on my site.  Do you think it could be an issue with missing a PHP class?
Title: Re: Automatic Attachment Rotation
Post by: dougiefresh on September 26, 2016, 04:16:33 PM
Quote from: kungfujoe on September 26, 2016, 04:05:47 PM
Hmmm...the pic doesn't rotate automatically on my site.  Do you think it could be an issue with missing a PHP class?
I doubt it.  If there was a missing PHP class, the topic display wouldn't function.  Let me investigate this bug report.....
Title: Re: Automatic Attachment Rotation
Post by: blunted on September 28, 2016, 10:07:06 PM
$txt['img_orientation'] = 'Rotate Clockwise'; $txt['img_orientation1'] = 'None'; $txt['img_orientation2'] = 'Horizontal Flip'; $txt['img_orientation3'] = 'Rotate 180°'; $txt['img_orientation4'] = 'Vertical Flip'; $txt['img_orientation5'] = 'Vertical Flip, Rotate 270°'; $txt['img_orientation6'] = 'Rotate 270°'; $txt['img_orientation7'] = 'Horizontal Flip, Rotate 270°'; $txt['img_orientation8'] = 'Rotate 90°';

getting this in admin
Title: Re: Automatic Attachment Rotation
Post by: dan4ever on September 30, 2016, 05:46:00 AM
Quote from: dougiefresh on September 26, 2016, 09:39:12 AM

:o Btw, what's with all the extra tags?  Makes your post incredibly difficult to read....  Anyway, I removed the extra tags, just so it's readable in quotes....  O:)


It comes when I copy/paste...
I don't like it at al...


/Dan
Title: Re: Automatic Attachment Rotation
Post by: dan4ever on September 30, 2016, 06:20:08 AM
Quote from: blunted on September 28, 2016, 10:07:06 PM
$txt['img_orientation'] = 'Rotate Clockwise'; $txt['img_orientation1'] = 'None'; $txt['img_orientation2'] = 'Horizontal Flip'; $txt['img_orientation3'] = 'Rotate 180°'; $txt['img_orientation4'] = 'Vertical Flip'; $txt['img_orientation5'] = 'Vertical Flip, Rotate 270°'; $txt['img_orientation6'] = 'Rotate 270°'; $txt['img_orientation7'] = 'Horizontal Flip, Rotate 270°'; $txt['img_orientation8'] = 'Rotate 90°';

getting this in admin


Open the file in Theme/default/languages with the name "Admin.english.php"  and at the end there should be a "?>"  and no one before.
Just move this   ?>   one to the end.


/Dan
Title: Re: Automatic Attachment Rotation
Post by: blunted on September 30, 2016, 07:29:14 AM
Quote from: dan4ever on September 30, 2016, 06:20:08 AM
Quote from: blunted on September 28, 2016, 10:07:06 PM
$txt['img_orientation'] = 'Rotate Clockwise'; $txt['img_orientation1'] = 'None'; $txt['img_orientation2'] = 'Horizontal Flip'; $txt['img_orientation3'] = 'Rotate 180°'; $txt['img_orientation4'] = 'Vertical Flip'; $txt['img_orientation5'] = 'Vertical Flip, Rotate 270°'; $txt['img_orientation6'] = 'Rotate 270°'; $txt['img_orientation7'] = 'Horizontal Flip, Rotate 270°'; $txt['img_orientation8'] = 'Rotate 90°';

getting this in admin

ty :)
Open the file in Theme/default/languages with the name "Admin.english.php"  and at the end there should be a "?>"  and no one before.
Just move this   ?>   one to the end.


/Dan
Title: Re: Automatic Attachment Rotation
Post by: dougiefresh on October 12, 2016, 10:18:01 AM
Uploaded v2.4 - October 12th, 2016
o Removed code that may flag images as processed when they haven't been.
o Added an additional check to make sure we only rotate IMAGES!
o Added code in the admin attachment area to clear image orientation flags.
o Added code to prevent double-processing of images and thumbnails.
o Fixed excluded database fields in Display.php database query.
o SMF 2.0: Modified admin attachment code to hook the previous function used.




@Everybody:  Hopefully, this update solves the problem of images not being rotated, but only if they have the EXIF information still in them....  This update will NOT fix images that have been re-encoded for any reason, as the EXIF information has been stripped out of the image.  This update WILL NOT fix any image that never had EXIF information in it.
Title: Re: Automatic Attachment Rotation
Post by: dougiefresh on October 13, 2016, 08:31:24 PM
UPDATE: I've been tinkering with the mod in the last few days, getting an option to allow the user to manually rotate their pictures while editing the post.  I've discovered that the attachment information given to the mod's code isn't reliable, and I've have to retool the mod in order to make it work for all pictures, both new and current pics.  I should have a new version out in the next few days, time allowing....

EDIT: Also, the thumbnail doesn't appear to update after the image is manually rotated, unless the browser is forced to reload everything.  This will be fixed with the next version, as well....
Title: Re: Automatic Attachment Rotation
Post by: dougiefresh on October 15, 2016, 08:14:44 PM
Uploaded v3.0 - October 15th, 2016
o Added code to the post editing template to manually rotate images.
o Added code to include timestamps on thumbnail URLs to circumvent browser caching.
o Fixed rotation code to get image format instead of relying on database information.
o Reduced potential database requests by merging attachment fetching database requests.
Title: Re: Automatic Attachment Rotation
Post by: dougiefresh on October 31, 2016, 07:49:57 AM
Uploaded v3.1 - October 31st, 2016
o Fixed missing array element errors when trying to get thumbnail attachment timestamp.
o Fixed issue where errors where generated because no filename was given to filemtime.
o Fixed LoadLanguage operation so that it does not rely on the global declaration.
Title: Re: Automatic Attachment Rotation
Post by: KungFuJoe on January 13, 2017, 01:17:42 PM
I'm not sure if this is browser specific but when I edit a post to rotate an image...when I choose a rotation from the drop down, it will automatically uncheck the attachment.  If someone isn't aware of this and saves the modified post, it will delete the attachment.

Any one else experiencing this?  I'm using Safari on a Mac (Sierra)
Title: Re: Automatic Attachment Rotation
Post by: KungFuJoe on January 13, 2017, 02:02:53 PM
Also, the rotation appears to happen counter clockwise, not clockwise.
Title: Re: Automatic Attachment Rotation
Post by: dougiefresh on January 13, 2017, 09:53:21 PM
Quote from: kungfujoe on January 13, 2017, 01:17:42 PM
I'm not sure if this is browser specific but when I edit a post to rotate an image...when I choose a rotation from the drop down, it will automatically uncheck the attachment.  If someone isn't aware of this and saves the modified post, it will delete the attachment.

Any one else experiencing this?  I'm using Safari on a Mac (Sierra)
Sorry, I can't reproduce this bug.  I've tested it on a PC with FireFox, Internet Explorer (gasp!) and Chrome.  None of the 3 browsers that I tested have unchecked the attachment box to the left of the attachment name.  I also looked in both the install_20x.xml as well as the Post.template.php, and there is nothing that would clear the attachment checkbox in a clean 2.0.13 forum with this mod installed.

There may be some conflict between this mod and another mod you might be running.  Without a mod list, SMF version number, and mod version number, I wouldn't be able to even guess as to why you're experiencing this issue......

Quote from: kungfujoe on January 13, 2017, 02:02:53 PM
Also, the rotation appears to happen counter clockwise, not clockwise.
I'm going to assume that you mean the image is rotated without you specifying the rotation value, since you haven't given me much to work on.  I can't reproduce this either.  If you change the rotation selection box and then click Post, of course it's going to rotate/flip the image in the direction specified.   That's by design.
Title: Re: Automatic Attachment Rotation
Post by: KungFuJoe on January 18, 2017, 02:14:40 PM
I think I'm still on SMF 2.0.12.  Haven't updated to 13 just yet.  I also quite a lot of mods so I will do some testing on my test site to see if one of them is affecting that checkbox.  Just to be clear, it only unchecks the attachment when I modify the rotation using the drop down.  The easy workaround is to simply recheck it.

As for the rotation, it rotates...but the opposite direction.

If you choose 90 degrees...it will rotate 90 degrees counter clockwise. 
Title: Re: Automatic Attachment Rotation
Post by: dougiefresh on January 21, 2017, 09:18:53 AM
Post your Themes/default/Post.template.php, so I might be able to see what is happening....
Title: Re: Automatic Attachment Rotation
Post by: landyvlad on January 26, 2017, 06:39:42 AM
OK so I installed it but

1) Is it supposed to auto-rotate existing attachments? Because it didn't in two cases (images do have basic EXIF data) .  I checked first - no then I clicked on the clear rotation flags.  Still no change.

2) Can the user ONLY rotate the attachment at time of upload, and not once attached?  Users often aren't sure of orientation and don't notice until its been attached. Can they then rotate it somehow?

Title: Re: Automatic Attachment Rotation
Post by: dougiefresh on January 26, 2017, 11:13:44 AM
Quote from: landyvlad on January 26, 2017, 06:39:42 AM
1) Is it supposed to auto-rotate existing attachments? Because it didn't in two cases (images do have basic EXIF data) .  I checked first - no then I clicked on the clear rotation flags.  Still no change.
If the mod CAN auto-rotate the image, it is supposed to.

Quote from: landyvlad on January 26, 2017, 06:39:42 AM
2) Can the user ONLY rotate the attachment at time of upload, and not once attached?  Users often aren't sure of orientation and don't notice until its been attached. Can they then rotate it somehow?
The user can edit the post, go down to the attachments, and instruct the forum to rotate it either 90, 180, or 270 degrees clockwise, and/or flip it horizontally or vertically.  Once that is complete, submit the post and it should be rotated when viewing it next time.
Title: Re: Automatic Attachment Rotation
Post by: landyvlad on January 26, 2017, 09:26:19 PM
OK cool thanks.

I checked one of the images with Photoshop to read the EXIF data - its has information on the camera etc but in none of the numerous potential categories of EXIF data did I see any image orientation flag....  Do you happen to know how this is recorded in EXIF data? (as in, what category, by what name/description)

Cheers
Title: Re: Automatic Attachment Rotation
Post by: dougiefresh on January 27, 2017, 10:11:25 PM
Quote from: landyvlad on January 26, 2017, 09:26:19 PM
I checked one of the images with Photoshop to read the EXIF data - its has information on the camera etc but in none of the numerous potential categories of EXIF data did I see any image orientation flag.... 
Well, that would be why the mod can't rotate the picture.....

Quote from: landyvlad on January 26, 2017, 09:26:19 PM
Do you happen to know how this is recorded in EXIF data? (as in, what category, by what name/description)
Sorry, I don't know how it is recorded in the EXIF data.  The EXIF reading library (http://www.phpclasses.org/package/1042-PHP-EXIF-information-reader-and-writer.html) that I included handles all of that processing if the built-in function exif_read_data doesn't exist. 
Title: Re: Automatic Attachment Rotation
Post by: landyvlad on January 29, 2017, 08:40:27 PM
Yeah I'm just a bit confused by the exif data as there is no field (blank or otherwise) which apparently pertains to rotation / orientation. Perhaps it's called something not obvious...

As I say the camera has recorded basic EXIF camera type etc and I am ASSUMING that orientation would be considered as "basic" data so would ASSUME that this would have been recorded as well.

I'll have to take a photo so I KNOW it has exif data and test it.  Cheers.
Title: Re: Automatic Attachment Rotation
Post by: PBSCreative on February 02, 2017, 11:01:52 AM
I've installed the extension, but it's still got the wrong orientation for images uploaded direct from iPhone.

Looking at Preview inspector on MacOS it puts the Orientation tag under "TIFF", not EXIF.

Could that be why it's being ignored?
Title: Re: Automatic Attachment Rotation
Post by: dougiefresh on February 05, 2017, 09:49:36 AM
@PBSCreative: Can you attach the image so that I can try to figure out how to detect the orientation correctly for that image?
Title: Re: Automatic Attachment Rotation
Post by: PBSCreative on February 06, 2017, 06:47:44 AM
Quote from: dougiefresh on February 05, 2017, 09:49:36 AM
@PBSCreative: Can you attach the image so that I can try to figure out how to detect the orientation correctly for that image?
Hi, thanks for responding. Here's an example, let's see if I can attach here or if I need to host it elsewhere for you to get an untangled version....

EXIF version difference maybe?
http://www.exiv2.org/tags-xmp-tiff.html
Title: Re: Automatic Attachment Rotation
Post by: dougiefresh on February 06, 2017, 09:53:22 AM
Uploaded v3.2 - February 6th, 2016
o Fixed function returning orientation when EXIF function is available.
o Fixed error generated by PBSCreative's image during alternative EXIF function testing.




@PBSCreative:  Thank you for attaching the picture.  Hopefully the problem has been fixed!
Title: Re: Automatic Attachment Rotation
Post by: PBSCreative on February 06, 2017, 10:28:03 AM
Quote from: dougiefresh on February 06, 2017, 09:53:22 AM
Uploaded v3.2 - February 6th, 2016
o Fixed function returning orientation when EXIF function is available.
o Fixed error generated by PBSCreative's image during alternative EXIF function testing.




@PBSCreative:  Thank you for attaching the picture.  Hopefully the problem has been fixed!

That's great, thanks. Unfortunately I can't test in our environment with this image as it keeps white screening, I'm assuming PHP is running into a problem or out of memory. If I remove this extension it's OK.
I'll have to look later, as I can't find where this host server has buried its php error reporting logs.
Title: Re: Automatic Attachment Rotation
Post by: KungFuJoe on February 06, 2017, 11:54:53 AM
I also get the white screen using 3.2 when trying to rotate an image after posting.

It appears to be somewhat random.  The good news is that...the one time it worked, it did correctly set the orientation for a photo I took with my iPhone.  The same image shows sideways when using 3.1 of the mod.
Title: Re: Automatic Attachment Rotation
Post by: dougiefresh on February 07, 2017, 11:44:27 AM
Quote from: kungfujoe on February 06, 2017, 11:54:53 AM
I also get the white screen using 3.2 when trying to rotate an image after posting.

It appears to be somewhat random.  The good news is that...the one time it worked, it did correctly set the orientation for a photo I took with my iPhone.  The same image shows sideways when using 3.1 of the mod.
I'm going to take a guess and say that is a out-of-memory issue.  I'll see if I can figure something out, so that at least you won't white-screen, which means: If it has the memory to do the rotation/flip thing, it'll do so.....
Title: Re: Automatic Attachment Rotation
Post by: landyvlad on February 08, 2017, 04:16:54 AM
best way to upgrade from 3.1 - uninstall 3.1 and install new one?
Title: Re: Automatic Attachment Rotation
Post by: PBSCreative on February 08, 2017, 06:47:22 AM
Quote from: landyvlad on February 08, 2017, 04:16:54 AM
best way to upgrade from 3.1 - uninstall 3.1 and install new one?
That's what I did without a hitch.
Title: Re: Automatic Attachment Rotation
Post by: dougiefresh on February 10, 2017, 01:04:38 PM
Uploaded v3.3 - February 10th, 2017
o Added code to attempt to get 128M of memory for our operations.
o Changed forum code to attempt to get 128M instead of 90M.




@kungfujoe:  Hopefully, this update fixes the out-of-memory issue you are seeing.....

Quote from: landyvlad on February 08, 2017, 04:16:54 AM
best way to upgrade from 3.1 - uninstall 3.1 and install new one?
That's the only way to upgrade.....
Title: Re: Automatic Attachment Rotation
Post by: PBSCreative on February 13, 2017, 05:34:58 AM
Quote from: dougiefresh on February 10, 2017, 01:04:38 PM
Uploaded v3.3 - February 10th, 2017
o Added code to attempt to get 128M of memory for our operations.
o Changed forum code to attempt to get 128M instead of 90M.

We did this in the code late Friday and it sorted it. In the logs it was just tipping over the 90M of allocated memory.
Title: Re: Automatic Attachment Rotation
Post by: KungFuJoe on February 13, 2017, 01:01:43 PM
I'm still getting the white screen issue with 3.3.
Title: Re: Automatic Attachment Rotation
Post by: KungFuJoe on February 13, 2017, 01:02:09 PM
Quote from: PBSCreative on February 13, 2017, 05:34:58 AM
Quote from: dougiefresh on February 10, 2017, 01:04:38 PM
Uploaded v3.3 - February 10th, 2017
o Added code to attempt to get 128M of memory for our operations.
o Changed forum code to attempt to get 128M instead of 90M.

We did this in the code late Friday and it sorted it. In the logs it was just tipping over the 90M of allocated memory.

Where in the logs can you see how much memory is being used?
Title: Re: Automatic Attachment Rotation
Post by: PBSCreative on February 15, 2017, 05:17:32 AM
Quote from: kungfujoe on February 13, 2017, 01:02:09 PM
Quote from: PBSCreative on February 13, 2017, 05:34:58 AM
Quote from: dougiefresh on February 10, 2017, 01:04:38 PM
Uploaded v3.3 - February 10th, 2017
o Added code to attempt to get 128M of memory for our operations.
o Changed forum code to attempt to get 128M instead of 90M.

We did this in the code late Friday and it sorted it. In the logs it was just tipping over the 90M of allocated memory.
When it was set to 90 it showed it was trying to allocate x bytes more than available.
Where in the logs can you see how much memory is being used?
Title: Re: Automatic Attachment Rotation
Post by: dougiefresh on February 15, 2017, 09:29:18 AM
@kungfujoe:  I'm guessing PBSCreative meant server logs, not SMF logs.  The location of such logs would be specific to the server you are running on.....
Title: Re: Automatic Attachment Rotation
Post by: KungFuJoe on February 16, 2017, 01:25:32 PM
I don't know if this is specific to the server I'm running on, but the issue I'm having with the white screen is with larger file sizes.  If I attach a <2MB pic...it's fine.  Tried a 2.8MB pic and white screen.

3.2 is better than 3.3 in this regard...in that I can attach larger sizes...but even with 3.2, when I tried to attach an 8MB pic, I got the white screen.
Title: Re: Automatic Attachment Rotation
Post by: PBSCreative on February 16, 2017, 01:59:42 PM
Quote from: kungfujoe on February 16, 2017, 01:25:32 PM
I don't know if this is specific to the server I'm running on, but the issue I'm having with the white screen is with larger file sizes.  If I attach a <2MB pic...it's fine.  Tried a 2.8MB pic and white screen.

3.2 is better than 3.3 in this regard...in that I can attach larger sizes...but even with 3.2, when I tried to attach an 8MB pic, I got the white screen.
The bigger the image, the more resources required to process it. So small images will be OK with less memory.
Title: Re: Automatic Attachment Rotation
Post by: KungFuJoe on February 16, 2017, 04:50:29 PM
Quote from: PBSCreative on February 16, 2017, 01:59:42 PM
Quote from: kungfujoe on February 16, 2017, 01:25:32 PM
I don't know if this is specific to the server I'm running on, but the issue I'm having with the white screen is with larger file sizes.  If I attach a <2MB pic...it's fine.  Tried a 2.8MB pic and white screen.

3.2 is better than 3.3 in this regard...in that I can attach larger sizes...but even with 3.2, when I tried to attach an 8MB pic, I got the white screen.
The bigger the image, the more resources required to process it. So small images will be OK with less memory.

Is that a limit with my server or with SMF?  Would like to be able to use this mod with larger file sizes...at least up to 10MB.

I also have a mod that reduces the file size and resolution of attached images.  This was so members didn't have to worry about reducing pics on their own (some are not technically savvy) and so I didn't have to worry about filling up my server storage anytime soon.  But it appears that this mod starts processing before the file size mod kicks in.
Title: Re: Automatic Attachment Rotation
Post by: KungFuJoe on February 16, 2017, 05:01:51 PM
Hmm...on a hunch, I uninstalled my mod that resizes attached images...reinstalled this mod (3.3) and then reinstalled my resize image mod...and now everything seems to work.  Was able to upload that 8MB pic I was referring to earlier.

So hope this does it.  :)
Title: Re: Automatic Attachment Rotation
Post by: dougiefresh on February 16, 2017, 06:11:01 PM
Quote from: kungfujoe on February 16, 2017, 05:01:51 PM
Hmm...on a hunch, I uninstalled my mod that resizes attached images...reinstalled this mod (3.3) and then reinstalled my resize image mod...and now everything seems to work.  Was able to upload that 8MB pic I was referring to earlier.

So hope this does it.  :)
Can you link to the mod you are talking about?  Maybe I can come up with some workaround for this situation.....
Title: Re: Automatic Attachment Rotation
Post by: KungFuJoe on February 17, 2017, 01:54:43 PM
Quote from: dougiefresh on February 16, 2017, 06:11:01 PM
Quote from: kungfujoe on February 16, 2017, 05:01:51 PM
Hmm...on a hunch, I uninstalled my mod that resizes attached images...reinstalled this mod (3.3) and then reinstalled my resize image mod...and now everything seems to work.  Was able to upload that 8MB pic I was referring to earlier.

So hope this does it.  :)
Can you link to the mod you are talking about?  Maybe I can come up with some workaround for this situation.....

http://custom.simplemachines.org/mods/index.php?mod=2206
Title: Re: Automatic Attachment Rotation
Post by: KungFuJoe on February 27, 2017, 11:43:55 AM
Had to remove v3.3 of this mod and revert back to 3.1.  3.2 and 3.3 both have the white screen issue on my server if I try to attach pic(s) that exceed around 8MB in total file size.

I think the reason why 3.1 "works" is because the auto image rotation actually doesn't work on my site...so pics still end up with the wrong orientation but at least I can go in and manually fix them with the mod.
Title: Re: Automatic Attachment Rotation
Post by: tanawat on March 09, 2017, 12:33:19 PM


after browse picture
(https://www.simplemachines.org/community/proxy.php?request=http%3A%2F%2Fupic.me%2Fi%2Fm3%2Funtitledsss.png&hash=a94a544ac0b64cab4448a7a7b9b1d8d67fc3422a) (http://upic.me/show/60450233)

when modify post
(https://www.simplemachines.org/community/proxy.php?request=http%3A%2F%2Fupic.me%2Fi%2F5k%2F0untitled44.png&hash=dc8d42488553dbbf05e63c7a9ec75176b0fb2495) (http://upic.me/show/60450234)

Appear when modify post isn't  it ?
Title: Re: Automatic Attachment Rotation
Post by: dougiefresh on March 09, 2017, 09:08:27 PM
@tanawat:  I'm sorry.  I don't understand your question....  (if there is indeed one...)
Title: Re: Automatic Attachment Rotation
Post by: Westwegoman on March 19, 2017, 03:23:58 PM
Quote from: KungFuJoe on January 18, 2017, 02:14:40 PM

As for the rotation, it rotates...but the opposite direction.

If you choose 90 degrees...it will rotate 90 degrees counter clockwise.

I'm having the same issue. SMF 2.0.13

Post.template.php attached

Also,

When browsing through files... Admin > Attachments and Avatars > Browse Files, is there a way to get the images to show up on that page that I'm missing?
Title: Re: Automatic Attachment Rotation
Post by: rajanmahajan on May 02, 2017, 09:11:46 AM
Hi.... It's not working properly....
Title: Re: Automatic Attachment Rotation
Post by: dougiefresh on August 04, 2017, 11:21:09 PM
UPDATE:  I apologize to everybody for taking so long to look into this mod's bug reports.  Hopefully, there will be an update shortly....  but I am working on it.
Title: Re: Automatic Attachment Rotation
Post by: dougiefresh on August 05, 2017, 11:25:26 AM
Uploaded v3.4 - August 5th, 2017
o Added code to dynamically adjust memory to try to stop white screen issues.




@KungFuJoe:  Hopefully, this update solves the white screen issues.  One caveat: If the mod can't allocate enough memory, it just won't do anything with the image.  I'll add something in the settings to log the issue when it happens for the next version....

@rajanmahajan:  Much wow.  So much description.  :-[

@Westwegoman:  Still looking into your bug report.  Please be patient...
Title: Re: Automatic Attachment Rotation
Post by: dougiefresh on August 16, 2017, 05:35:28 PM
Anyone care to comment on the last version?
Title: Re: Automatic Attachment Rotation
Post by: aegersz on August 19, 2017, 04:19:41 AM
I LOVE this mod because suddenly all my pics were rotated 90 degrees anti-clockwise.

you are a ******ing LEGEND dougie. At least half of my website mods were written by you.

EXCELLENT JOB !

the only glitch was that i i had to add a blank line before your check for the Hacker poll thing and then it installed like a dream.
Title: Re: Automatic Attachment Rotation
Post by: dougiefresh on September 04, 2017, 11:22:36 PM
Uploaded v3.5 - September 4th, 2017
o Added support for SMF 2.1 Beta 3.
o Removed support for SMF 2.1 Beta 2.
o Added ability to log "unable to allocate enough memory" errors.
o Added setting to enable logging of "unable to allocate enough memory" errors.
o Replaced code for fallback mod-defined imagerotate function.
o FALLBACK: Try to get 256MB of memory if memory_get_usage function not available.




@aegersz:  Blank line issue has been fixed as well...  Thanks for the bug report!
Title: Re: Automatic Attachment Rotation
Post by: Baitjunky on September 08, 2017, 03:30:24 PM
Im getting this error after install on 2.0.14

Parse error: syntax error, unexpected end of file in /home/baitjunkys/public_html/forum/Sources/Subs-AutoRotation.php on line 464
Title: Re: Automatic Attachment Rotation
Post by: dougiefresh on September 08, 2017, 08:30:17 PM
Uploaded v3.6 - September 8th, 2017
o Fixed 2 syntax errors in Subs-AutoRotation.php.




@Baitjunky:  Man, oh man, typo city here.... Thank you for reporting the syntax error.  It's been fixed with this version!
Title: Re: Automatic Attachment Rotation
Post by: aegersz on September 10, 2017, 12:28:57 AM
sorry dougie but another minor conflict in what appears to be a duplication (the two install failing lines do the same thing ?) in  Sources/Display.php ; all your other mods are at the lastest version, installed and working but i am assuming they are conflicting with this one now ... see the attached screenshots:
Title: Re: Automatic Attachment Rotation
Post by: dougiefresh on September 10, 2017, 04:13:06 PM
I'll take a look at it when I get home from work.
Title: Re: Automatic Attachment Rotation
Post by: aegersz on September 12, 2017, 08:57:11 AM
no hurry. at all. maybe it's my fault ? that's highly likely but then again i think i run almost all of your mods.
Title: Re: Automatic Attachment Rotation
Post by: dougiefresh on September 12, 2017, 10:01:06 AM
It's definitely a conflict between Post and PM Inline Attachments and this mod.....  Still looking at how to resolve this...
Title: Re: Automatic Attachment Rotation
Post by: dougiefresh on September 12, 2017, 10:23:40 AM
Uploaded v3.7 - September 12th, 2017
o Resolved conflict with Post and PM Inline Attachments (http://custom.simplemachines.org/mods/index.php?mod=3770).  No functionality change.




@aegersz:  This update should take care of the conflict that you reported.
Title: Re: Automatic Attachment Rotation
Post by: aegersz on September 12, 2017, 10:30:09 AM
so it does ! thanks again, dougie !
Title: Re: Automatic Attachment Rotation
Post by: aegersz on September 12, 2017, 12:32:30 PM
whoops, the mod broke my forum and i had made a bunch of changes. I only suspected this because ./Sources/Display.php got modified ...

see https://www.simplemachines.org/community/index.php?topic=556162
Title: Re: Automatic Attachment Rotation
Post by: dougiefresh on September 12, 2017, 11:47:09 PM
Uploaded v3.7.1 - September 12th, 2017
o SMF 2.0: Fixed a syntax typo in Sources/Display.php
o SMF 2.1: Fixed a syntax typo in Sources/Subs-Attachments.php



(https://avatanplus.com/files/resources/mid/56aced0bcec19152937df647.png)
@aegersz:  I swear I'll get this right....  Might not be today, but I'll get it right....  O:)
Title: Re: Automatic Attachment Rotation
Post by: aegersz on September 13, 2017, 01:26:29 AM
the art of programming is the practise of bugging.

I totally forgot that I put this mod back on and then went away,  uninstalled another mod by making manual code changes, ugraded 2 more of your mods and forgot to enable php logging  :(

I spent hours trying to get my site to work ... this was the first time I ever put a mod on (this one) without testing first ... it's not your fault, I didn't follow protocol and your handy auto-refresh mod delete mod sent me on a tidy-up frenzy. love that guy !
Title: Re: Automatic Attachment Rotation
Post by: aegersz on October 04, 2017, 09:36:55 AM
It's me again - i have been busy ensuring that i am running your latest releases but when i installed this on my test system, i got this error:

Parse error: syntax error, unexpected ';', expecting ')' in /var/www/html/Sources/Display.php on line 1665

so i suggest to replace:
'href' => $scripturl . '?action=dlattach . ';ts=' . $time . ';topic=' . $msg_topic . '.0;attach=' . $attachment['id_attach'],

with:
'href' => $scripturl . '?action=dlattach;ts=' . $time . ';topic=' . $msg_topic . '.0;attach=' . $attachment['id_attach'],

is this right or have i just missed something ? it works on my test system now but it's your code ...
Title: Re: Automatic Attachment Rotation
Post by: dougiefresh on October 09, 2017, 09:03:50 AM
Uploaded v3.8 - October 9th, 2017
o Fixed syntax error in code that builds the attachment link.




@aegersz:  Thank you for reporting the bug!  It's been fixed for this version.
Title: Re: Automatic Attachment Rotation
Post by: landyvlad on December 18, 2017, 07:31:17 AM
What is the update process please?  Is it just upload and install the new one, or do I uninstall./delete the old one first?
(It'd be cool if this info was included in the description of the mod, for easy reference)

Thanks
Title: Re: Automatic Attachment Rotation
Post by: dougiefresh on December 18, 2017, 09:15:35 AM
Quote from: landyvlad on December 18, 2017, 07:31:17 AM
What is the update process please?  Is it just upload and install the new one, or do I uninstall./delete the old one first?
(It'd be cool if this info was included in the description of the mod, for easy reference)
First, Package Manager won't allow you to install a newer version of a mod while an older version is installed.  If the package supports upgrading, Package Manager will give you the option to upgrade to the new version.  Most of my mods do not support upgrades in that fashion, mostly because some servers have issues with multiple install XML files and aren't smart enough to make it work....

The proper way to upgrade any mod that doesn't give the option through Package Manager is to uninstall the current version of the mod, then install  the new version.  Immediately deleting the old version is not mandatory at any stage of the upgrade process, although if you are happy with the new version, deletion of the old version is recommended.
Title: Re: Automatic Attachment Rotation
Post by: @rjen on December 30, 2017, 06:35:39 AM
I am getting this error when testing the MOD.

This error pops up when I rotate an attached impage when editing the post...
Is it just me?

https://test.fjr-club.nl/index.php?action=post2;start=0;msg=300786;df4bebae3674=18d5e877907afa4d5c23988966f6f164;board=26
8: A non well formed numeric value encountered
Bestand: /home/deb77453/domains/fjr-club.nl/public_html/test/Sources/Subs-AutoRotation.php
Regel: 90
Title: Re: Automatic Attachment Rotation
Post by: @rjen on December 30, 2017, 07:32:07 AM
Another question: I am mainly looking at the function to rotate attachments manually from the post area.
Since I re-encode all attachments in the forum, the automatic rotation does not seem to work upon upload (is that correct?)

Then when I am in the post area the options for rotation seem a bit 'many' for my users and a bit confusing.
Question 1:
Rotation says 'Clockwise', but when I rotate 90 degrees it actually rotates counter-clockwise (!)

Question 2:
Is there a way to sort the options provided differently?

Quote'No Change';
'Horizontal Flip';
'Rotate 180 deg Clockwise';
'Vertical Flip';
'Vertical Flip, Rotate 270 deg Clockwise';
'Rotate 270 deg Clockwise';
'Horizontal Flip, Rotate 270 deg Clockwise';
'Rotate 90 deg Clockwise';

For my users the rotate options are the most used, and actually those are throughout the list...
I want to present it like this:

Quote'No Change';
'Rotate 90 deg Clockwise';
'Rotate 180 deg Clockwise';
'Rotate 270 deg Clockwise';
'Horizontal Flip';
'Vertical Flip';
'Horizontal Flip, Rotate 270 deg Clockwise';
'Vertical Flip, Rotate 270 deg Clockwise';
Title: Re: Automatic Attachment Rotation
Post by: @rjen on December 30, 2017, 08:00:06 AM
Quote from: @rjen on December 30, 2017, 06:35:39 AM
I am getting this error when testing the MOD.

This error pops up when I rotate an attached impage when editing the post...
Is it just me?

https://test.fjr-club.nl/index.php?action=post2;start=0;msg=300786;df4bebae3674=18d5e877907afa4d5c23988966f6f164;board=26
8: A non well formed numeric value encountered
Bestand: /home/deb77453/domains/fjr-club.nl/public_html/test/Sources/Subs-AutoRotation.php
Regel: 90

I just checked the code, and I see it is in the memory limit.

Now I am using this MOD to set a memory limit. Is there a conflict perhaps?
http://custom.simplemachines.org/mods/index.php?mod=4111
Title: Re: Automatic Attachment Rotation
Post by: landyvlad on January 17, 2018, 05:10:39 AM
Bit of a problem.

Trying to uninstall v 3.3 to update to 3.8

The uninstall test shows the following error.

1.   Replace   ./Sources/Post.php   Test failed
2.   Replace   ./Sources/Post.php   Test successful
3.   Replace   ./Sources/Post.php   Test successful

Suggestions / help welcomed. :)
Title: Re: Automatic Attachment Rotation
Post by: landyvlad on January 20, 2018, 02:16:31 AM
dougiefresh  - should I

1. Uninstall, ignoring the errors, or
2 Just install the new one over the top, or
3 Something else ?
Title: Re: Automatic Attachment Rotation
Post by: GL700Wing on January 20, 2018, 04:31:27 AM
Quote from: @rjen on December 30, 2017, 08:00:06 AM
Quote from: @rjen on December 30, 2017, 06:35:39 AM
I am getting this error when testing the MOD.

This error pops up when I rotate an attached impage when editing the post...
Is it just me?

https://test.fjr-club.nl/index.php?action=post2;start=0;msg=300786;df4bebae3674=18d5e877907afa4d5c23988966f6f164;board=26
8: A non well formed numeric value encountered
Bestand: /home/deb77453/domains/fjr-club.nl/public_html/test/Sources/Subs-AutoRotation.php
Regel: 90

I just checked the code, and I see it is in the memory limit.

Now I am using this MOD to set a memory limit. Is there a conflict perhaps?
http://custom.simplemachines.org/mods/index.php?mod=4111
I'm getting the same error message and I've confirmed it is a PHP 7.x issue (eg, earlier versions of PHP weren't as pedantic) and is not caused by a conflict with any other mods.

Line 89 of ./Sources/Subs-AutoRotation.php has the following code:
$memoryLimit = ini_get('memory_limit');
and '$memoryLimit' is the value of memory_limit in your php.ini file (eg, 256M).

PHP 7.x doesn't like that '$memoryLimit' contains a non-numeric character (ie, the letter 'M') and that's why it's complaining when it is used in the calculation on line 90:
$memoryRequested = (int) $memoryLimit + ceil(($currentMemory - $memoryLimit * pow(1024, 2)) / pow(1024, 2));

The fix is to change line 89 of ./Sources/Subs-AutoRotation.php to use the PHP '(float)' function to remove non-numeric characters from memory_limit in php.ini when it becomes '$memoryLimit' (eg, 256 will be returned).
$memoryLimit = (float) ini_get('memory_limit');

Title: Re: Automatic Attachment Rotation
Post by: dougiefresh on January 21, 2018, 08:27:51 PM
Quote from: landyvlad on January 17, 2018, 05:10:39 AM
Bit of a problem.

Trying to uninstall v 3.3 to update to 3.8

The uninstall test shows the following error.

1.   Replace   ./Sources/Post.php   Test failed
2.   Replace   ./Sources/Post.php   Test successful
3.   Replace   ./Sources/Post.php   Test successful

Suggestions / help welcomed. :)
Attach your Sources/Post.php and I'll try to help you.  Don't and I simply can't....




@GL700Wing:  Will this fix work with PHP 5.x, though?  Cause I'll be happy to implement it, but I need to know if it'll cause issues for PHP 5.x.....
Title: Re: Automatic Attachment Rotation
Post by: GL700Wing on January 22, 2018, 12:42:43 AM
Quote from: dougiefresh on January 21, 2018, 08:27:51 PM@GL700Wing:  Will this fix work with PHP 5.x, though?  Cause I'll be happy to implement it, but I need to know if it'll cause issues for PHP 5.x.....
Don't know - my main websites are PHP 7.x (and I can't set the version of PHP to be different on a per-forum basis within a website) but I do have one website where I can setup a PHP 5.x forum - will try and get time tonight to try it and let you know.
Title: Re: Automatic Attachment Rotation
Post by: landyvlad on January 22, 2018, 02:12:30 AM
dougiefresh when I'm next at a computer that will allow me to download and upload such files (e.g at home), I will do so.
Title: Re: Automatic Attachment Rotation
Post by: landyvlad on January 22, 2018, 06:00:32 PM
It's OK success !@
I uninstalled it and then found the one edit that the uninstaller could not do, manually edited that out.
Installed new version.  All good !

Thanks.
Title: Re: Automatic Attachment Rotation
Post by: GL700Wing on January 22, 2018, 08:34:05 PM
Quote from: GL700Wing on January 22, 2018, 12:42:43 AM
Quote from: dougiefresh on January 21, 2018, 08:27:51 PM@GL700Wing:  Will this fix work with PHP 5.x, though?  Cause I'll be happy to implement it, but I need to know if it'll cause issues for PHP 5.x.....
Don't know - my main websites are PHP 7.x (and I can't set the version of PHP to be different on a per-forum basis within a website) but I do have one website where I can setup a PHP 5.x forum - will try and get time tonight to try it and let you know.
Hmm - I typed a reply to this last night but it's not here - it was very late so might have forgotten to click the 'Post' button.

I tested the '(float)' fix with SMF 2.0.15 and PHP 5.6 and, in addition to rotating the images, it did not cause any errors to be logged (no other mods were installed on the forum I tested it on).
Title: Re: Automatic Attachment Rotation
Post by: -Rock Lee- on February 12, 2018, 07:47:21 PM
I just realized the current but you can see at that moment it did not translate, that's why I leave it to Spanish now! 8)


Regards!
Title: Re: Automatic Attachment Rotation
Post by: dougiefresh on February 13, 2018, 10:02:05 PM
Uploaded v3.9 - February 13th, 2018
o Added Spanish Latin translation, courtsey of Rock Lee (https://www.simplemachines.org/community/index.php?action=profile;u=322597).
o Added translators section to README.txt.
o Added LICENSE.txt to satisfy licensing concerns.




@Rock Lee:  Thank you for the translation!!  It's been included in this version!
Title: Re: Automatic Attachment Rotation
Post by: GL700Wing on February 17, 2018, 06:26:49 AM
Quote from: dougiefresh on February 13, 2018, 10:02:05 PM
Uploaded v3.9 - February 13th, 2018
Would you please include the fix for A non well formed numeric value encountered (https://www.simplemachines.org/community/index.php?topic=544111.msg3958439#msg3958439) in the next release - as requested I have verified (https://www.simplemachines.org/community/index.php?topic=544111.msg3958933#msg3958933) that it works with SMF 2.0.15 and PHP 5.6.
Title: Re: Automatic Attachment Rotation
Post by: dougiefresh on February 17, 2018, 11:30:43 AM
Uploaded v3.10 - February 17th, 2018
o Included "Non well-formed number" fix by GL700Wing (https://www.simplemachines.org/community/index.php?action=profile;u=112942), as discussed here (https://www.simplemachines.org/community/index.php?topic=544111.msg3958439#msg3958439).




@GL700Wing:  Whoops!  I completely forgot about that fix when I released the last version!  It's been included for this version, though!  Thanks!
Title: Re: Automatic Attachment Rotation
Post by: GL700Wing on February 18, 2018, 10:53:42 PM
I installed this mod and discovered that, as per this post (https://www.simplemachines.org/community/index.php?topic=544111.msg3954833#msg3954833), images didn't rotate as expected - in fact 'Rotate 90o Clockwise' and 'Rotate 270o Clockwise' both had the opposite effect to what I expected.  In addition, I thought some of the 'action' descriptions (eg, 'Rotate 270o Clockwise' ) could be made clearer (eg, 'Rotate 90o Left').

So - I've made the following minor changes on my forum.

I changed the text strings in ./Themes/default/languages/AutoRotation.english.php as follows:
$txt['img_orientation'] = 'Rotate/Flip';
$txt['img_orientation1'] = 'No Change';
$txt['img_orientation2'] = 'Horizontal Flip';
$txt['img_orientation3'] = 'Rotate 180&deg;';
$txt['img_orientation4'] = 'Vertical Flip';
$txt['img_orientation5'] = 'Vertical Flip, Rotate 90&deg; Right';
$txt['img_orientation6'] = 'Rotate 90&deg; Right';
$txt['img_orientation7'] = 'Horizontal Flip, Rotate 90&deg; Right';
$txt['img_orientation8'] = 'Rotate 90&deg; Left';
$txt['img_rotate'] = 'Rotate/Flip Images';


And I've changed the drop-down menu selection order in ./Sources/ManageAttachments.php and ./Themes/default/Post.template.php to:
<option value="0">' . $txt['img_orientation1'] . '</option><option value="6">' . $txt['img_orientation6'] . '</option><option value="8">' . $txt['img_orientation8'] . '</option><option value="3">' . $txt['img_orientation3'] . '</option><option value="2">' . $txt['img_orientation2'] . '</option><option value="4">' . $txt['img_orientation4'] . '</option><option value="7">' . $txt['img_orientation7'] . '</option><option value="5">' . $txt['img_orientation5'] . '</option>
Title: Re: Automatic Attachment Rotation
Post by: dougiefresh on February 20, 2018, 07:36:30 PM
@Rock Lee:  Can you translate these strings properly for this new version?  Thanks!
$txt['img_orientation'] = 'Rotate/Flip';
$txt['img_orientation1'] = 'No Change';
$txt['img_orientation2'] = 'Horizontal Flip';
$txt['img_orientation3'] = 'Rotate 180&deg;';
$txt['img_orientation4'] = 'Vertical Flip';
$txt['img_orientation5'] = 'Vertical Flip, Rotate 90&deg; Right';
$txt['img_orientation6'] = 'Rotate 90&deg; Right';
$txt['img_orientation7'] = 'Horizontal Flip, Rotate 90&deg; Right';
$txt['img_orientation8'] = 'Rotate 90&deg; Left';
$txt['img_rotate'] = 'Rotate/Flip Images';


@GL700Wing:  I'm implementing the changes you suggested.  Once Rock Lee gives me the translations, I'll publish the new version!
Title: Re: Automatic Attachment Rotation
Post by: -Rock Lee- on February 20, 2018, 08:04:11 PM
No problem, here they are translated 8)

$txt['img_orientation'] = 'Girar / Voltear';
$txt['img_orientation1'] = 'Ning&uacute;n cambio';
$txt['img_orientation2'] = 'Flip horizontal';
$txt['img_orientation3'] = 'Girar 180&deg;';
$txt['img_orientation4'] = 'Vertical Flip';
$txt['img_orientation5'] = 'Vertical Flip, Girar 90&deg; Derecha';
$txt['img_orientation6'] = 'Girar 90&deg; Derecha';
$txt['img_orientation7'] = 'Flip horizontal, Girar 90&deg; Derecha';
$txt['img_orientation8'] = 'Girar 90&deg; Izquierda';
$txt['img_rotate'] = 'Girar / Voltear im&aacute;genes';


Whatever you need, call me...


Regards!
Title: Re: Automatic Attachment Rotation
Post by: dougiefresh on February 20, 2018, 10:15:39 PM
Uploaded v3.11 - February 20th, 2018
o Updated Spanish Latin translations, courtsey of Rock Lee (https://www.simplemachines.org/community/index.php?action=profile;u=322597).
o Changed rotation/flip strings for better understandability, per GL700Wing (https://www.simplemachines.org/community/index.php?action=profile;u=112942)'s post above.
o Changed order of rotation/flip strings in templates, per GL700Wing (https://www.simplemachines.org/community/index.php?action=profile;u=112942)'s post above.




@Rock Lee and @GL700Wing:  Thank you both for your contributions!  They are appreciated, since lately I can't seem to get my sh#t together well enough....  Plus I'm sick with a damn sinus infection from hell!   UGH!!!
Title: Re: Automatic Attachment Rotation
Post by: GL700Wing on February 20, 2018, 10:29:14 PM
You're welcome - hope you're feeling better soon.
Title: Re: Automatic Attachment Rotation
Post by: @rjen on February 21, 2018, 05:13:32 PM
Quote from: GL700Wing on February 18, 2018, 10:53:42 PM
I installed this mod and discovered that, as per this post (https://www.simplemachines.org/community/index.php?topic=544111.msg3954833#msg3954833), images didn't rotate as expected - in fact 'Rotate 90o Clockwise' and 'Rotate 270o Clockwise' both had the opposite effect to what I expected.  In addition, I thought some of the 'action' descriptions (eg, 'Rotate 270o Clockwise' ) could be made clearer (eg, 'Rotate 90o Left').

So - I've made the following minor changes on my forum.

I changed the text strings in ./Themes/default/languages/AutoRotation.english.php as follows:
$txt['img_orientation'] = 'Rotate/Flip';
$txt['img_orientation1'] = 'No Change';
$txt['img_orientation2'] = 'Horizontal Flip';
$txt['img_orientation3'] = 'Rotate 180&deg;';
$txt['img_orientation4'] = 'Vertical Flip';
$txt['img_orientation5'] = 'Vertical Flip, Rotate 90&deg; Right';
$txt['img_orientation6'] = 'Rotate 90&deg; Right';
$txt['img_orientation7'] = 'Horizontal Flip, Rotate 90&deg; Right';
$txt['img_orientation8'] = 'Rotate 90&deg; Left';
$txt['img_rotate'] = 'Rotate/Flip Images';


And I've changed the drop-down menu selection order in ./Sources/ManageAttachments.php and ./Themes/default/Post.template.php to:
<option value="0">' . $txt['img_orientation1'] . '</option><option value="6">' . $txt['img_orientation6'] . '</option><option value="8">' . $txt['img_orientation8'] . '</option><option value="3">' . $txt['img_orientation3'] . '</option><option value="2">' . $txt['img_orientation2'] . '</option><option value="4">' . $txt['img_orientation4'] . '</option><option value="7">' . $txt['img_orientation7'] . '</option><option value="5">' . $txt['img_orientation5'] . '</option>

Nice to see that you picked up my request. I made these changes as well, but got not reply on the question. Thought it was forgotten...
Title: Re: Automatic Attachment Rotation
Post by: dougiefresh on February 21, 2018, 07:52:48 PM
Sorry about that, @rjen!  I really didn't know how to fix it....
Title: Re: Automatic Attachment Rotation
Post by: @rjen on February 22, 2018, 04:14:09 AM
Tested, and looking good.

In the explanation you may also want to update the option descriptions?

It still reads:

QuoteManual Rotation Options
o No Change
o Horizontal Flip
o Rotate 180 degrees
o Vertical Flip
o Vertical Flip, Rotate 270 degrees clockwise. (90 degrees counter-clockwise)
o Rotate 270 degrees clockwise. (90 degrees counter-clockwise)
o Horizontal Flip, Rotate 270 degrees clockwise. (90 degrees counter-clockwise)
o Rotate 90 degrees clockwise.

May be changed to:

o No Change
o Rotate 90 degrees Right
o Rotate 90 degrees Left.
o Rotate 180 degrees
o Horizontal Flip
o Vertical Flip
o Horizontal Flip, Rotate 90 degrees Right
o Vertical Flip, Rotate 90 degrees Right

Find attached the language file for Dutch..
Title: Re: Automatic Attachment Rotation
Post by: GL700Wing on February 22, 2018, 04:26:48 AM
Quote from: @rjen on February 22, 2018, 04:14:09 AM
May be changed to:

o No Change
o Rotate 90 degrees Right
o Rotate 90 degrees Left.
o Rotate 180 degrees
o Horizontal Flip
o Vertical Flip
o Horizontal Flip, Rotate 90 degrees Right
o Vertical Flip, Rotate 90 degrees Right

It may even be possible to use the 'degrees' symbol ...
o No Change
o Rotate 90° Right
o Rotate 90° Left
o Rotate 180°
o Horizontal Flip
o Vertical Flip
o Horizontal Flip, Rotate 90° Right
o Vertical Flip, Rotate 90° Right
Title: Re: Automatic Attachment Rotation
Post by: dougiefresh on February 22, 2018, 09:41:51 AM
Uploaded v3.12 - February 22nd, 2018
o Added Dutch translation, courtsey of @rjen (https://www.simplemachines.org/community/index.php?action=profile;u=287786)!
o 2nd attempt: Changed order of rotation/flip strings in templates, per GL700Wing (https://www.simplemachines.org/community/index.php?action=profile;u=112942)'s post above.
o Changed documentation to reflect new order of manual rotation options.




@rjen:  Thank you for the translation!  It's been included in this version!  I've also "reeditted" the install XML files so that the option-order changes are present, cause I'm not sure if they got into the last version....

EDIT:  I finally saw what you were talking about: it's in the documentation....  It's been fixed!  Thanks!
Title: Re: Automatic Attachment Rotation
Post by: Rob Lightbody on March 18, 2018, 10:20:38 AM
Installed and working on 2.0.15.  Thank you.

Only hiccup is when you go to browse files, then rotate an image, the button at the bottom, and the confirmation, both warn you about deleting files, even though I'm only rotating them.
Title: Re: Automatic Attachment Rotation
Post by: dougiefresh on March 29, 2018, 12:13:00 PM
Uploaded v4.0 - March 27th, 2018
o Per GL700Wing (https://www.simplemachines.org/community/index.php?action=profile;u=112942), fixed issue where images with very large dimensions could not be rotated (Image Processing Memory Limit (http://custom.simplemachines.org/mods/index.php?mod=4111) mod may also be required if issue persists).
o Per GL700Wing (https://www.simplemachines.org/community/index.php?action=profile;u=112942), code added to automatically resize images in new and existing topics.
o Per GL700Wing (https://www.simplemachines.org/community/index.php?action=profile;u=112942), added automatic rotation and automatic resize for images in PMs if 'PM Attachments' (https://custom.simplemachines.org/mods/index.php?mod=1974) mod is installed.




@GL700Wing:  Thank you for the new version!  It's been converted for use with SMF 2.1 Beta 3, as well!

@The QE2 Story Forum:  I'm not sure where you are talking about.  Are you talking about the admin area?
Title: Re: Automatic Attachment Rotation
Post by: Rob Lightbody on March 30, 2018, 11:48:13 AM
Hi there,

I uninstalled 3.12, and tried to install 4.0, but it has failed because the following line in subs-graphics is different on my installation.  I believe this is because I am also using the "Resize Attached Images" mod.

$success = imagejpeg($dst_img, $destName, min($modSettings['attachment_image_compression'], 100));


For now, I've re-installed 3.12 again.

Cheers,

- Rob
Title: Re: Automatic Attachment Rotation
Post by: dougiefresh on March 30, 2018, 12:31:59 PM
@The QE2 Story Forum: The installation readme notes that the Resize Attached Images mod should NOT be installed prior to the installation of this mod, as they contain similar, but not the same, functionality....  IMO, this should imply that if you have it installed, you should uninstall it before installing this mod...
Title: Re: Automatic Attachment Rotation
Post by: Rob Lightbody on April 01, 2018, 10:08:46 AM
Quote from: dougiefresh on March 30, 2018, 12:31:59 PM
@The QE2 Story Forum: The installation readme notes that the Resize Attached Images mod should NOT be installed prior to the installation of this mod, as they contain similar, but not the same, functionality....  IMO, this should imply that if you have it installed, you should uninstall it before installing this mod...

Thank you for replying, and sorry for not reading the instructions properly!   OK so I uninstalled 3.12 version of this mod, and then I uninstalled "resize attached images" too... then I reinstalled version 4 of this mod and - all is well!  Thank you!
Title: Re: Automatic Attachment Rotation
Post by: Rob Lightbody on April 02, 2018, 08:46:50 AM
Just a note - I'm having terrible problems with this now I'm afraid.   It doesn't mean that I don't recommend it to others, just that its caused me a lot of bother overall.

Even though it installs and uninstalls cleanly, I'm getting issues such as zero-byte uploads, and I even have a topic that won't display now until I uninstall the mod...

https://www.theqe2story.com/forum/index.php?action=admin;area=manageattachments;sa=browse;sort=date;desc
2: filemtime(): stat failed for /home/robligh/public_html/forum/attachments/57406_a5e04f2e038e80b207c22b83c11a78a07b0bd6c4
File: /home/robligh/public_html/forum/Sources/ManageAttachments.php(383) : runtime-created function
Line: 17

Title: Re: Automatic Attachment Rotation
Post by: GL700Wing on April 02, 2018, 03:49:54 PM
Quote from: The QE2 Story Forum on April 02, 2018, 08:46:50 AM
Even though it installs and uninstalls cleanly, I'm getting issues such as zero-byte uploads, and I even have a topic that won't display now until I uninstall the mod...
With the zero-byte upload issue - what are the file size and image dimensions of the original image (eg, 7.4Mb, 4608x3456) you are trying to upload?

Have you tried running Attachments and Avatars -> File Maintenance -> Attachment Integrity Check to check for/fix any database errors?

If you disable Resize existing images when the mod is installed does the topic that won't display show correctly?  Also, what are the file size and image dimensions of the attached images (eg, 7.4Mb, 4608x3456) in that topic?

Do you have the Image Processing Memory Limit (http://custom.simplemachines.org/mods/index.php?mod=4111) mod installed and, if so, how much memory is it configured with?
Title: Re: Automatic Attachment Rotation
Post by: dougiefresh on April 02, 2018, 04:54:58 PM
Uploaded v4.1 - March 30th, 2018
o Changed some code to avoid undefined array element errors.
o Per GL700Wing (https://www.simplemachines.org/community/index.php?action=profile;u=112942), added check to see if file size is greater than 0.




@The QE2 Story Forum:  Some code has been changed to deal with certain situations better, however, no number of changes will ever be able to fix an attachment whose size is now 0 bytes....  Maybe this version will fix the errors you're encountering....
Title: Re: Automatic Attachment Rotation
Post by: Fat Rat on April 02, 2018, 05:53:32 PM
I have just installed v4.1 and now I can't access the admin area of my site (v-strom.co.uk) please help?
Title: Re: Automatic Attachment Rotation
Post by: GL700Wing on April 02, 2018, 06:33:55 PM
Quote from: Fat Rat on April 02, 2018, 05:53:32 PM
I have just installed v4.1 and now I can't access the admin area of my site (v-strom.co.uk) please help?
There is a problem in the file ./Sources/Subs-AutoRotation.php - if you delete that file you'll be able to access the Admin menu again and uninstall the package.
Title: Re: Automatic Attachment Rotation
Post by: Fat Rat on April 02, 2018, 06:41:23 PM
You are a star, thank you.
Title: Re: Automatic Attachment Rotation
Post by: GL700Wing on April 02, 2018, 07:10:02 PM
Quote from: Fat Rat on April 02, 2018, 05:53:32 PM
I have just installed v4.1 and now I can't access the admin area of my site (v-strom.co.uk) please help?
There is a problem in the file ./Sources/Subs-AutoRotation.php - fix on line 522* as follows:
Find:
$sizeLimit = !empty(($modSettings[($pm ? 'pmA' : 'a') . 'ttachmentSizeLimit']) ? $modSettings[($pm ? 'A' : 'a') . 'ttachmentSizeLimit'] * 1024 : 0;
Replace With:
$sizeLimit = !empty($modSettings[($pm ? 'pmA' : 'a') . 'ttachmentSizeLimit']) ? $modSettings[($pm ? 'A' : 'a') . 'ttachmentSizeLimit'] * 1024 : 0;



* to remove extra '(' character after '!empty'
Title: Re: Automatic Attachment Rotation
Post by: GL700Wing on April 02, 2018, 10:53:42 PM
Quote from: The QE2 Story Forum on March 18, 2018, 10:20:38 AM
Only hiccup is when you go to browse files, then rotate an image, the button at the bottom, and the confirmation, both warn you about deleting files, even though I'm only rotating them.
This issue is caused by the same confirmation message being used for both rotating/flipping images and deleting any attachment type because both actions are done through a single button.

The fix is to create two buttons - one for each action.

In ./Sources/ManageAttachments.php
Find:
'value' => '<input type="submit" name="remove_submit" class="button_submit" value="' . $txt['quickmod_delete_selected'] . '" onclick="return confirm(\'' . $txt['confirm_delete_attachments'] . '\');" />',
Replace With:
'value' => '<input type="submit" name="rotate_submit" class="button_submit" value="' . $txt['img_rotate'] . '" onclick="return confirm(\'' . $txt['img_rotate_confirm'] . '\');" />
<input type="submit" name="remove_submit" class="button_submit" value="' . $txt['quickmod_delete_selected'] . '" onclick="return confirm(\'' . $txt['confirm_delete_attachments'] . '\');" />',


Add to ./Themes/default/languages/AutoRotation.english.php
$txt['img_rotate_confirm'] = 'Are you sure you want to apply the image rotate/flip changes?';
Title: Re: Automatic Attachment Rotation
Post by: dougiefresh on April 03, 2018, 05:46:23 PM
Uploaded v4.2 - April 3rd, 2018
o Per GL700's post (https://www.simplemachines.org/community/index.php?topic=544111.msg3967893#msg3967893), fixed syntax error in Subs-AutoRotation.php.
o Per GL700's post (https://www.simplemachines.org/community/index.php?topic=544111.msg3967928#msg3967928), fixed issue where same message for rotating images as deleting images.
o Per GL700Wing (https://www.simplemachines.org/community/index.php?action=profile;u=112942), changed code to avoid "white screen of death" when rotating images manually.




@GL700Wing:  Thank you for all the changes and fixes you've sent!  They've been included in this version!

@Everybody Else:  Sorry about the delay in responding.  I've been dealing with not-fun family issues lately and haven't been able to respond....
Title: Re: Automatic Attachment Rotation
Post by: dougiefresh on April 05, 2018, 08:38:00 PM
Uploaded v4.3 - April 5th, 2018
o Fixed code to avoid distorting aspect ratio of resized pictures.
o Added code to avoid resizing images if they are under/at admin-set dimensions.
o Per GL700Wing (https://www.simplemachines.org/community/index.php?action=profile;u=112942), changed required for Image Processing Memory Limit mod was made.
o Per GL700Wing (https://www.simplemachines.org/community/index.php?action=profile;u=112942), fixed issue where JPEG quality/dimensions settings are empty.




@Everybody:  Sorry, everybody!  GL700Wing and I keep finding things to fix/tweak....  Hopefully, this update solves some problems people have been experiencing....
Title: Re: Automatic Attachment Rotation
Post by: Fat Rat on April 06, 2018, 08:55:41 AM
I uploaded 4.2 and didn't install because of the following errors?

Title: Re: Automatic Attachment Rotation
Post by: Shambles on April 06, 2018, 09:15:43 AM
Quote from: Fat Rat
I uploaded 4.2 and didn't install because of the following errors?



Just do the changes to that file manually - there are only 4 small changes to make:

The parser on the mod download page will show you the edits you need to make to that file.
Title: Re: Automatic Attachment Rotation
Post by: GL700Wing on April 06, 2018, 09:54:22 AM
Quote from: dougiefresh on April 05, 2018, 08:38:00 PM
@Everybody:  Sorry, everybody!  GL700Wing and I keep finding things to fix/tweak....  Hopefully, this update solves some problems people have been experiencing....
dougiefresh (https://www.simplemachines.org/community/index.php?action=profile;u=253913) and I have been working together to implement automatic image resizing in conjunction with automatic JPEG image rotation and, having found/fixed/tweaked a few more things today, I expect the next release to be the last for a while.
Title: Re: Automatic Attachment Rotation
Post by: dougiefresh on April 06, 2018, 12:33:23 PM
I've got to backport the changes to SMF 2.0 that GL700Wing made into SMF 2.1 Beta 3.  However, I've got a problem where I get this message from SMF 2.1 Beta 3 (fresh install):
Notice: Undefined index: htmlspecialchars in D:\Website\clean21\Sources\Errors.php on line 69

Fatal error: Function name must be a string in D:\Website\clean21\Sources\Errors.php on line 69

Running PHP 5.6.34....  Totally confused....  And no, I DO NOT want to run the GitHub version, as there are too many changes that can easily break my mods....  I won't support the GitHub version until it becomes the official beta 4/RC1/whatever....

Nevermind, the backup I imported in order to restore my database evidently was causing these issues....  Back to backporting.  I would guess that the new version won't be out until tomorrow, cause I have to go to work in about an hour.... (sigh)
Title: Re: Automatic Attachment Rotation
Post by: dougiefresh on April 07, 2018, 12:23:31 PM
Uploaded v4.4 - April 7th, 2018
o SMF 2.0: Fixed XML installer error concerning JPEG quality size.
o Per GL700Wing (https://www.simplemachines.org/community/index.php?action=profile;u=112942), added JPEQ quality check to prevent unnecessary image resizing.
o Per GL700Wing (https://www.simplemachines.org/community/index.php?action=profile;u=112942), fixed code to prevent converting to JPEG when admin option unchecked.
o Per GL700Wing (https://www.simplemachines.org/community/index.php?action=profile;u=112942), added option to disable automatic image rotation.
o Per GL700Wing (https://www.simplemachines.org/community/index.php?action=profile;u=112942), added option to disable automatic image resizing.
o Fixed a few possible undefined index array errors.




@GL700:  All changes you've made in the mod are now available in the SMF 2.1 Beta 3 version of the mod as well!  Thanks again!
Title: Re: Automatic Attachment Rotation
Post by: dougiefresh on April 08, 2018, 11:36:19 AM
Uploaded v4.5 - April 8th, 2018
o NOTE: Statement in last version changelog "added option to disable automatic image rotation" was incomplete.
o Per GL700Wing (https://www.simplemachines.org/community/index.php?action=profile;u=112942), added option to disable automatic image rotation FOR EXISTING IMAGES.
o Per GL700Wing (https://www.simplemachines.org/community/index.php?action=profile;u=112942), fixed default JPEG quality value to be 100 instead of 0.
o Per GL700Wing (https://www.simplemachines.org/community/index.php?action=profile;u=112942), added mime type test prior to check for orientation.
Title: Re: Automatic Attachment Rotation
Post by: @rjen on April 08, 2018, 03:23:02 PM
I am getting an error on Post.php.

It seems to me you are addressing this code looking for 4 tabs, there are only 3 in the original code...


Code: (Zoek) [Selecteer]
// Check the total upload size for this post...

Code: (Voeg toe voor) [Selecteer]
// Automatic Attachment Rotation (and Resize) alteration:
if (!empty($modSettings['attachment_auto_rotate']))
{
require_once($sourcedir . '/Subs-AutoRotation.php');
AutoRotation_Inbound($n);
}
Title: Re: Automatic Attachment Rotation
Post by: @rjen on April 08, 2018, 03:42:01 PM
Now the next question: how does this Mod behave when this one is already active?

http://custom.simplemachines.org/mods/index.php?mod=2206

Checking the settings between my Test and my Porductive forum it seems that the code is cery similar?
Can I just deactivate the other one?
Title: Re: Automatic Attachment Rotation
Post by: Rob Lightbody on April 08, 2018, 04:13:00 PM
Quote from: @rjen on April 08, 2018, 03:42:01 PM
Now the next question: how does this Mod behave when this one is already active?

Read the compatibility notes on the first post... I fell into the same trap.

I'm currently waiting to reinstall this once it seems stable.
Title: Re: Automatic Attachment Rotation
Post by: @rjen on April 08, 2018, 04:17:30 PM
Quote from: The QE2 Story Forum on April 08, 2018, 04:13:00 PM
Quote from: @rjen on April 08, 2018, 03:42:01 PM
Now the next question: how does this Mod behave when this one is already active?

Read the compatibility notes on the first post... I fell into the same trap.

I'm currently waiting to reinstall this once it seems stable.


Similar functionality ? It seems to be mostly the same code! Even the text strings are the same...
Title: Re: Automatic Attachment Rotation
Post by: GL700Wing on April 09, 2018, 01:22:08 AM
Uploaded v4.6 - April 8th, 2018
o Per @rjen's post (https://www.simplemachines.org/community/index.php?topic=544111.msg3968596#msg3968596) fixed installation error in ./Sources/Post.php.
o Moved test for disabled automatic image rotation from ./Sourecs/Post.php to ./Sources/Subs-AutoRotation.php so that image resizing still occurs when automatic image rotation is disabled.
o Fixed bug in ./Sources/Subs-AutoRotation.php where image filename suffix was not being changed following reformat.
o Added redirect to 'Attachment Settings' following installation.
Title: Re: Automatic Attachment Rotation
Post by: GL700Wing on April 09, 2018, 01:23:32 AM
Prior to v4.x of this mod 'white screen of death' issues were still encountered with JPEG images that had very large dimensions and which needed to be rotated (and even installing the Image Processing Memory Limit (https://custom.simplemachines.org/mods/index.php?mod=4111) mod and configuring it to use 512M of memory didn't resolve the issue) - the only fix for this issue is to resize JPEG images before attempting to rotate them.




Quote from: @rjen on April 08, 2018, 04:17:30 PM
Similar functionality ? It seems to be mostly the same code! Even the text strings are the same...
Some of the functionality/text strings is/are the same but there are some important differences between this mod and Resize Attached Images (https://custom.simplemachines.org/mods/index.php?mod=2206) - particularly in relation to how 'Resize existing images' works (this is done in ./Sources/Display.php).

The Resize Attached Images (https://custom.simplemachines.org/mods/index.php?mod=2206) mod has the following shortcomings in relation to the processing of existing images:
1.  It does not reformat non-JPEG images to JPEG unless 'Resize existing images' is also enabled;
2.  It does not apply a reduction in JPEQ quality unless the image width/height are greater than max width/height; and
3.  It converts non-JPEG images to JPEG when image attachment width/height are greater than max width/height even if 'Reformat non-JPEG images to JPEG' is disabled.

Finally, this mod fully integrates rotating and/or resizing images in topics and, if the PM Attachments (https://custom.simplemachines.org/mods/index.php?mod=1974) mod is already installed, also in PMs.




I'd like to apologise for the inconvenience that has been caused by the number of updates this mod has been through in the last 10 days - dougiefresh (https://www.simplemachines.org/community/index.php?action=profile;u=253913) and I have been working together to integrate the resizing functionality (which I have had working in a slightly different format on my forums for almost a year) with the 'Automatic Attachment Rotation' mod and obviously we've encountered a few issues along the way.

That said, I am confident the latest version will work as expected/intended.
Title: Re: Automatic Attachment Rotation
Post by: @rjen on April 09, 2018, 05:46:03 AM
I will do some testing with the latest package in my Test system.

In the meantime I have updated the Dutch Language files (with the strings I already translated for the other MOD  ;D ). Find these attached...
Title: Re: Automatic Attachment Rotation
Post by: @rjen on April 11, 2018, 05:28:49 PM
The MOD is working fine and I have applied it for productive use where it has been for a few days, no errors reported and all seems OK.

I do have a few recommendations though:
1. The UTF8 language files for English are missing in the install package: those should really be included. (same applies to the Inline Attachments MOD)

2. I find that there is an annoying 'feature':

When I go to 'browse files' in the admin section there is the function added to Rotate / Flip the file
Next to this option are the standard checkboxes to select multiple files.

Now when I use the checkbox and Click on the Flip/Rotate Images Button, the image is actually DELETED! Regardless of wether or not the checkbox is selected: it should only cause the selected processing option to be executed...
That is pretty dangerous.

In my opinion clicking the Flip/Rotate button should NEVER cause an image to be deleted!
Title: Re: Automatic Attachment Rotation
Post by: GL700Wing on April 11, 2018, 11:20:45 PM
Uploaded v4.7 - April 12th, 2018
o Updated Dutch translation courtsey of @rjen (https://www.simplemachines.org/community/index.php?action=profile;u=287786)
o As per @rjen's post (https://www.simplemachines.org/community/index.php?topic=544111.msg3968843#msg3968843) included English UTF8 language file.
o As per @rjen's post (https://www.simplemachines.org/community/index.php?topic=544111.msg3968843#msg3968843) fixed issue where attachment is deleted when checkbox for deleting attachment is selected and Rotate/Flip Images button is clicked.
o Some code tidy-up in ./Sources/Display.php for JPEG Quailty processing.




@rjen : (https://www.simplemachines.org/community/index.php?action=profile;u=287786) Thanks for the Dutch language files and bug report.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on April 26, 2018, 07:58:37 PM
Uploaded v5.0 - April 27th, 2018
o Added option for resizing existing images in either manual or batch mode.
o Changed code to only display rotate/flip options for image attachments when modifying a post.
o Fixed problem with readme file that was causing it not to display during package installation.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: @rjen on April 27, 2018, 11:22:07 AM
In the new admin option to Resize Existing Images  a list is presented of images to be processed.

Two problems with the list:

1. This list cannot be sorted (by any column)
2. The browse pages option does not function: even though the page number changes, the listed images remain unchanged...

Title: Re: Automatic Attachment Rotation (and Resize)
Post by: @rjen on April 27, 2018, 12:31:38 PM
In addition: I was looking at the new text strings to add these to the dutch language files.

Now I am confused: as part of the install package you have included an additonal text file : ResizeExistingImages.english.php and ResizeExistingImages.english-utf8.php, but the install file is also adding the same text strings to Modifications.english.php!

It seems that this is not intentional... can you please correct this?

I will provide the dutch files if the files are the correct way...
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Rob Lightbody on April 27, 2018, 01:03:07 PM
Hi,

I've just installed v5.0 after giving you a few weeks to iron out your niggles, and so far so good.  I'll feed back again in a few days if I see any issue (or not).

Keep up the good work (but don't go overboard and make this mod too large and complex!!)

Cheers,

- Rob
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on April 27, 2018, 11:49:26 PM
Uploaded v5.1 - April 28th, 2018
o Per @rjen (https://www.simplemachines.org/community/index.php?topic=525705.msg3970385#msg3970385) - fixed issue that prevented Post and PM Inline Attachment (https://custom.simplemachines.org/mods/index.php?mod=3770) inline attachment numbers from being incremented when modifying a post.
o Per @rjen (https://www.simplemachines.org/community/index.php?topic=544111.msg3970388#msg3970388) - fixed issues with sorting and browsing list of images to be resized/reformatted.
o Per @rjen (https://www.simplemachines.org/community/index.php?topic=544111.msg3970392#msg3970392) - load required language file rather than add text strings to other language files.




Thanks @rjen (https://www.simplemachines.org/community/index.php?action=profile;u=287786) for the bug reports.

In relation to the adding of the text strings to the Modifications.english.php file : this was the approach taken in the mod I based the manual/batch resizing code on.  That said, I have now updated the code in this mod to load the required language file instead.

QuoteI will provide the dutch files if the files are the correct way...
Thanks - if you provide the ResizeExistingImages.dutch.php and ResizeExistingImages.dutch-utf8.php files I'll add them to the next release.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on April 28, 2018, 12:05:20 AM
Quote from: The QE2 Story Forum on April 27, 2018, 01:03:07 PMI've just installed v5.0 after giving you a few weeks to iron out your niggles, and so far so good.  I'll feed back again in a few days if I see any issue (or not).
Thanks - I've just uploaded v5.1 so you can try that version now!  ;)

QuoteKeep up the good work (but don't go overboard and make this mod too large and complex!!)
I don't think much more functionality will be added to this mod.

That said I know that having the option to resize existing image attachments (using manual and/or batch processing modes) is really important for forums that have not previously implemented image attachment dimension/filesize restrictions for several reasons:
1. Smaller image attachment filesizes will result in posts that load more quickly;
2. Reducing the filesize of image attachments has the potential to significantly reduce the disk space used by attachments; and
3. Probably no so important but less website bandwidth will be used.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: @rjen on April 28, 2018, 03:36:37 AM
Thanks for sorting out the language strings. Find attached the missing dutch files...

Small problem with the links to images in the list.
For most images the link works: it brings me directly to the image in the post. For some the link brings me to the first message in the post...

I noticed that the link under the standard option (Browse files > Attachments) always work.
Theze are formatted as such:
https://test.fjr-club.nl/index.php?topic=14573.msg257357#msg257357
https://test.fjr-club.nl/index.php?topic=14573.msg213612#msg213612

The links in the new list (Browse files > Resize Existing Images) are formatted as below:
https://test.fjr-club.nl/index.php?topic=14573.0.msg257357#msg257357
https://test.fjr-club.nl/index.php?topic=14573.0.msg213612#msg213612

These links do not always work. It seems to be related the length of the topics: in a long topic it does not work correctly..

It seems to be caused by the .0 added after the topic ID..
?topic=14573.0.msg


Apart from that the packages seems to be fine.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on April 28, 2018, 05:22:14 AM
V5.2 - April 28th, 2018
o Per @rjen (https://www.simplemachines.org/community/index.php?topic=544111.msg3970435#msg3970435) - fixed image and post links for images in Browse files > Resize Existing Images list.
o Per @rjen (https://www.simplemachines.org/community/index.php?topic=544111.msg3970435#msg3970435) - added Dutch language files.




@rjen (https://www.simplemachines.org/community/index.php?action=profile;u=287786) - Many thanks for your testing and feedback - I really appreciate it!
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Rob Lightbody on April 28, 2018, 05:44:41 AM
Hi there,

I woke up to lots of errors in my forum, and have uninstalled this again (v 5.0).  Do you think, from looking below, that 5.2 will resolve this?  I have uninstalled 5.0 and installed 5.2.

This was the first error, from a guest


https://www.theqe2story.com/forum/index.php?/topic,8446.0.html
The database value you're trying to insert does not exist: width
Function: loadAttachmentContext
File: /public_html/forum/Sources/Display.php
Line: 1584

Then followed by hundreds of errors from everyone when accessing that topic.


2: rename(/home/robligh/public_html/forum/attachments/58323_58fd5a2be5327a3ac9844bdf2b5c8440a0a01323.temp,/home/robligh/public_html/forum/attachments/58323_58fd5a2be5327a3ac9844bdf2b5c8440a0a01323): No such file or directory
File: /home/robligh/public_html/forum/Sources/Display.php
Line: 1542



2: getimagesize(/home/robligh/public_html/forum/attachments/58323_58fd5a2be5327a3ac9844bdf2b5c8440a0a01323): failed to open stream: No such file or directory
File: /home/robligh/public_html/forum/Sources/Display.php
Line: 1545



https://www.theqe2story.com/forum/index.php?/topic,8446.0.html
2: filesize(): stat failed for /home/robligh/public_html/forum/attachments/58323_58fd5a2be5327a3ac9844bdf2b5c8440a0a01323
File: /home/robligh/public_html/forum/Sources/Display.php
Line: 1548


Thanks.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Rob Lightbody on April 28, 2018, 06:23:17 AM
Second, separate feedback.

Now on 5.2.

Someone has managed to upload a huge 10mb photo - 6000x4000 px.  I've tried to use the resize existing images feature to shrink this down, but it seems to just ignore me when I try - doesn't do anything, and no error logged either.   If its any help, this is the post with the huge image on it - https://www.theqe2story.com/forum/index.php/topic,8333.msg96611.html#msg96611

Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on April 28, 2018, 09:10:20 AM
Quote from: The QE2 Story Forum on April 28, 2018, 06:23:17 AM
Someone has managed to upload a huge 10mb photo - 6000x4000 px.  I've tried to use the resize existing images feature to shrink this down, but it seems to just ignore me when I try - doesn't do anything, and no error logged either.
Have you checked the error_log file on the server to see if it contains any error messages?

QuoteIf its any help, this is the post with the huge image on it - https://www.theqe2story.com/forum/index.php/topic,8333.msg96611.html#msg96611
I've downloaded that photo and tested the following scenarios on my test forum and the image is successfully resized to 1024x682 with a filesize of ~57Kb every time:

Scenario One:
1. The following Attachment Settings all saved as blank: 'Max attachment size per post', 'Max size per attachment', 'JPEG quality factor', 'Maximum width of attached images' and 'Maximum height of attached images'.
2.  The Attachment Setting 'Resize existing images' is disabled.
3. The 10Mb/6000x4000Px photo is attached to a post - the image information shows the photo is 10715.44 kB, 6000x4000.
4. The following Attachment Settings are configured using values shown at the end of this post: 'Max attachment size per post', 'Max size per attachment', 'JPEG quality factor', 'Maximum width of attached images' and 'Maximum height of attached images'
5. The image attachment is selected from the Admin -> Attachments and Avatars -> Browse Files -> Resize Existing Images list and successfully resized by clicking on 'Resize Existing Images'/'Resize and/or Reformat Existing Images'.

Scenario Two:
1. The following Attachment Settings all saved as blank: 'Max attachment size per post', 'Max size per attachment', 'JPEG quality factor', 'Maximum width of attached images' and 'Maximum height of attached images'.
2.  The Attachment Setting 'Resize existing images' is disabled.
3. The 10Mb/6000x4000Px photo is attached to a post - the image information shows the photo is 10715.44 kB, 6000x4000.
4. The following Attachment Settings are configured using values shown at the end of this post: 'Max attachment size per post', 'Max size per attachment', 'JPEG quality factor', 'Maximum width of attached images' and 'Maximum height of attached images'
5. The Attachment Setting 'Resize existing images' is enabled.
6. The image attachment is automatically resized the next time the post containing the image is displayed.

Scenario Three:
1. The following Attachment Settings are configured using values shown at the end of this post: 'Max attachment size per post', 'Max size per attachment', 'JPEG quality factor', 'Maximum width of attached images' and 'Maximum height of attached images'
2. The Attachment Setting 'Resize existing images' is enabled.
3. The 10Mb/6000x4000Px photo is attached to a post  - the image information is automatically resized when the post is saved.




The fact that the image is being shown in the list of images that can be resized indicates that you have configured at least some of the following Attachment Settings:  'Max attachment size per post', 'Max size per attachment', 'JPEG quality factor', 'Maximum width of attached images' and 'Maximum height of attached images' - you should also make sure the Attachment Setting 'Resize existing images' is enabled.

Given that the photo resizes correctly on my test forum with three different scenarios (and no error messages) the only other thing I can suggest you try is to save the photo to your own computer, edit the topic and clear the checkbox for the existing image attachment and attach the photo as a new attachment.



Suggested Attachment Settings:
Max attachment size per post: 2048
Max size per attachment: 1024
JPEG quality factor: 80
Maximum width of attached images: 1024
Maximum height of attached images:1024

Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on April 28, 2018, 09:18:42 AM
Quote from: The QE2 Story Forum on April 28, 2018, 05:44:41 AM
I woke up to lots of errors in my forum, and have uninstalled this again (v 5.0).  Do you think, from looking below, that 5.2 will resolve this?  I have uninstalled 5.0 and installed 5.2.
I suspect those error messages are being generated because the Attachment Setting 'Resize existing images' is enabled and there is a missing or corrupted image attachment -  Admin => Forum => Attachments and Avatars => File Maintenance => Attachment Integrity Check should be run and issues corrected.

If the errors persist disable the Attachment Setting 'Resize existing images'.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Rob Lightbody on April 28, 2018, 09:39:07 AM
Thanks for replying/trying to help.

OK so ....

I have max attachment size per post and max size per attachment deliberately set to 0 (disable) to allow my very non-technical forum users to upload big files.  I don't want it stopping them trying to upload a big photo, I just want it to shrink it down without htem knowing what its doing.  If i set these to 1024/2048 as you suggest, I can't upload that big image at all.

I did have resize existing imagest ticked.

And I've had JPEG quality set to 85, and max height/width both at 1280 for a long time.

I can't see any errors at all on the server, it just stubbornly refuses to do anything to this particular photo!
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on April 28, 2018, 10:07:40 AM
Quote from: The QE2 Story Forum on April 28, 2018, 09:39:07 AM
I have max attachment size per post and max size per attachment deliberately set to 0 (disable) to allow my very non-technical forum users to upload big files.  ...  If i set these to 1024/2048 as you suggest, I can't upload that big image at all.
That's really interesting because I can definitely upload that big image with those settings (ie, Max attachment size per post: 2048 and Max size per attachment: 1024) and the reason for this is that the attachment size is checked after the image has been resized.

I'll send you a PM with details of a login you can use on my test forum (which is a recent copy of my production forum) so that you can try with that big image yourself (you can either create a new topic or reply to an existing one).




FYI: My test forum is configured with the following Attachment Settings:
Max attachment size per post: 2048
Max size per attachment: 1024
Reformat non-JPEG images to JPEG: Enabled
Resize existing images: Enabled
JPEG quality factor: 80
Maximum width of attached images: 1024
Maximum height of attached images:1024
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Rob Lightbody on April 28, 2018, 10:10:42 AM
Quote from: GL700Wing on April 28, 2018, 10:07:40 AM
That's really interesting because I can definitely upload that big image with those settings (ie, Max attachment size per post: 2048 and Max size per attachment: 1024) and the reason for this is that the attachment size is checked after the image has been resized.

Hi.  I did wonder about that, which is why I did the test - it sounds like my forum/server is simply not managing to resize that image (by whatever method), but does manage to upload it OK.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on April 28, 2018, 10:34:47 AM
Quote from: The QE2 Story Forum on April 28, 2018, 10:10:42 AM
Quote from: GL700Wing on April 28, 2018, 10:07:40 AM
That's really interesting because I can definitely upload that big image with those settings (ie, Max attachment size per post: 2048 and Max size per attachment: 1024) and the reason for this is that the attachment size is checked after the image has been resized.

Hi.  I did wonder about that, which is why I did the test - it sounds like my forum/server is simply not managing to resize that image (by whatever method), but does manage to upload it OK.
The forum I've been using to test/check the resizing of your large photo is running SMF 2.0.15 and has 135 mods (including this one) installed plus lots of other customisations.

I'm beginning to wonder if you have a conflicting mod installed or if an earlier version of this mod or a mod like Resize Attached Images (https://custom.simplemachines.org/mods/index.php?mod=2206) did not uninstall fully/correctly.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Rob Lightbody on April 28, 2018, 11:08:01 AM
I've also now spotted another corrupt (missing) image in my error log - seems to be happening at random.  The thumbnail is still there, but the image attachment has gone.  This wasn't happening (ever) when I only had Resize Attached Images installed.   In the attachments folder, instead of the file, is one with the same name, with .temp at the end, and zero bytes.

Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on April 28, 2018, 11:33:00 AM
Quote from: The QE2 Story Forum on April 28, 2018, 11:08:01 AM
I've also now spotted another corrupt (missing) image in my error log - seems to be happening at random.  The thumbnail is still there, but the image attachment has gone.  This wasn't happening (ever) when I only had Resize Attached Images installed.   In the attachments folder, instead of the file, is one with the same name, with .temp at the end, and zero bytes.
Have you run Admin => Forum => Attachments and Avatars => File Maintenance => Attachment Integrity Check and corrected any issues it has found?

Do you know if the corrupt/missing image was originally a JPG image or was it some other image type (eg, PNG, GIF, etc)?

Did you have the 'Resize Existing Images' option enabled with the "Resize Attached Images" mod?




The '.temp' file is created when the original image is resized but at that point both image files exist (ie, the original image file and the resized copy with the '.temp' extension) and the '.temp' file is renamed to the original file name only if the resizing was successful.  As such there shouldn't be any '.temp' files.  I suggest you disable the 'Resize Existing Images' option while I investigate further.

I also originally had "Resize Attached Images" mod installed but I haven't encountered the issues you're reporting and my forum has more than 8,000 image attachments (which I resized on my test forum using this mod).
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Rob Lightbody on April 28, 2018, 11:47:07 AM
This mod is causing me to lose attachments.  I've now uninstalled it, and reverted to the Resize Attached Images, which has never caused such a problem.

The integrity check does highlight issues (due to the images this mod is causing me to lose) but was coming up clean before I tried it again.

I'm sure it isn't happening in ever case (or I'd have lost loads more images) - no idea what the pattern is.  Yes they're all JPGs.

Thanks for your help, but thats me giving up again.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on April 28, 2018, 11:55:27 AM
Quote from: The QE2 Story Forum on April 28, 2018, 11:47:07 AM
This mod is causing me to lose attachments.  I've now uninstalled it, and reverted to the Resize Attached Images, which has never caused such a problem.

The integrity check does highlight issues (due to the images this mod is causing me to lose) but was coming up clean before I tried it again.

I'm sure it isn't happening in ever case (or I'd have lost loads more images) - no idea what the pattern is.  Yes they're all JPGs.

Thanks for your help, but thats me giving up again.
If you disable the 'Resize Existing Images' option this mod will not touch images in existing posts.

I'll do further testing and checking but given this mod is not working properly on your forum anyway I don't know if I'll be able to solve these issues.  Do you have a test forum that is a copy of your current production forum where you test/check mods?
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: @rjen on April 28, 2018, 03:06:33 PM
I verified the working of the mod including the Batch task on a test site and It all seems allright, moved it into productive use.

When testing I  got to a better understanding of the working of the process and consequently I had to update some of the dutch language strings to better reflect the correct function. This includes a special note in string $txt['resize_images_desc'] to explain that the list of files for Resize Existing Images only displays images that qualify for resizing under the current settings.

I would suggest including that explanation in the English file too in a future version of the mod...

Title: Re: Automatic Attachment Rotation (and Resize)
Post by: dougiefresh on April 28, 2018, 05:06:18 PM
Sorry, I've been dealing with some issues lately and haven't been following the forum as closely as I suppose I should have....  I'll take a look into the reports...
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on April 30, 2018, 05:23:27 AM
V5.3 - April 30th, 2018
o Per @rjen (https://www.simplemachines.org/community/index.php?topic=544111.msg3970490#msg3970490) - updated Dutch language files for 'Resize Exisitng Images'.
o Updated English language files for 'Resize Exisitng Images' to provide more detailed description for manual/batch options.
o Changed behaviour of automatic image resizing when displaying a post so that images are only resized if 'Resize existing images' is selected (in previous versions of this mod they were also resized when 'Reformat non-JPEG images to JPEG' was selected).
o Resolved issue that was causing image files saved with '_JPG' in their filename to be incorrectly renamed to '_jpg' in the database (this only affected image attachments created with SMF 1.x).
o Added option to keep backup of original image file when Attachment Setting 'Resize exisitng images' is enabled.
o Updated image resizing code for automatic, manual and batch resizing modes to create backup of the original image file and restore it if the new image file is empty.




@rjen (https://www.simplemachines.org/community/index.php?action=profile;u=287786) : Thanks for the updated Dutch language files - two new text strings have been added to AutoRotation.dutch.php/AutoRotation.dutch-utf8.php.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: @rjen on April 30, 2018, 02:40:01 PM
Quote from: GL700Wing on April 30, 2018, 05:23:27 AM
@rjen (https://www.simplemachines.org/community/index.php?action=profile;u=287786) : Thanks for the updated Dutch language files - two new text strings have been added to AutoRotation.dutch.php/AutoRotation.dutch-utf8.php.

Updated files attached...
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: -Rock Lee- on April 30, 2018, 08:02:05 PM
I have a doubt with the phrase "...image file will be kept in the <i>attachmentsPreREI<i> directory." is the SMF default folder? I do not have my computer at hand to test what it refers to (if I realize the doubts of some translations). I want to thank you for the effort to update both the modification, it denotes a lot of appreciation to collaborate. Now I'm having problems with the internet, but as soon as I finish and check my translations, I'll update the updated versions.


Regards!
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on April 30, 2018, 09:59:12 PM
Quote from: Rock Lee on April 30, 2018, 08:02:05 PM
I have a doubt with the phrase "...image file will be kept in the <i>attachmentsPreREI<i> directory." is the SMF default folder?
The directory/folder name should have been shown in italics (ie, attachmentsPreREI) so I have fixed that text formatting in the language files.
Also, the directory/folder 'attachmentsPreREI' is created in the default SMF forum directory/folder (ie, in the same directory/folder as the 'attachments' directory/folder) so I've updated the help text/description to include this information.

QuoteI want to thank you for the effort to update both the modification, it denotes a lot of appreciation to collaborate.
Thank you - I'm very grateful to @dougiefresh (https://www.simplemachines.org/community/index.php?action=profile;u=253913) for the great mods he has developed and for allowing me to work on this mod.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on April 30, 2018, 10:04:07 PM
V5.4 - May 1st, 2018
o Per @rjen (https://www.simplemachines.org/community/index.php?topic=544111.msg3970720#msg3970720) - updated Dutch language files.
o Per Rock Lee (https://www.simplemachines.org/community/index.php?topic=544111.msg3970759#msg3970759) - fixed text formatting error for attachmentsPreREI directory name text string in language files and updated help text/description relating to the saving of original image files to the attachmentsPreREI directory.




@rjen (https://www.simplemachines.org/community/index.php?action=profile;u=287786) : Thanks for the updated Dutch language files.
Rock Lee (https://www.simplemachines.org/community/index.php?action=profile;u=322597) : Thanks for the feedback.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: -Rock Lee- on May 01, 2018, 06:21:29 PM
No problem @GL700Wing I leave the improved translations in some points I saw were loose also fix some errors overlooked. Likewise, anything you tell me :P and thanks for so much (I already have to go through your web there are several mod I have the translations @dougiefresh I'm only in a public network and I hesitate to login but I'll be able to do it and I'll help you with several vi's that are not published here).


Regards!
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Rob Lightbody on May 06, 2018, 06:17:33 AM
OK so reinstalled just now.  Installed with no errors.

Have set it up as per the attached.

I immediately went to an image that was uploaded a few days ago, that had appeared upside down.  I did modify post, rotate 180 degrees, and I it only rotated the thumbnail.... when I click the thumbnail, the full photo is still the wrong way around.  ..

Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Tonyvic on May 06, 2018, 07:15:31 AM
I see from your attachment I note that 'Re-encode potentially dangerous image attachments' is active.
I don't ues the Mod but could it be due to
QuoteNOTE: SMF contains an option called Re-encode potentially dangerous image attachments, which is turned on by default.  This re-encoding removes the orientation information from attachments (amongst other things), which means attachments uploaded prior to this mod being installed will NOT be able to rotated properly, as the EXIF information is missing from the re-encoded attachment file!
which is stated on the Mod page?
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Rob Lightbody on May 06, 2018, 12:03:51 PM
Thanks. My mistake!  Yes it seems happier now...
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on May 07, 2018, 09:08:09 AM
V5.5 - May 7th, 2018
o Per Rock Lee (https://www.simplemachines.org/community/index.php?topic=544111.msg3970888#msg3970888) - updated/added Spanish langage files.
o Per The QE2 Story Forum (https://www.simplemachines.org/community/index.php?topic=544111.msg3971411#msg3971411) and Tonyvic (https://www.simplemachines.org/community/index.php?topic=544111.msg3971413#msg3971413) - added note about "Attachment Settings => Re-encode potentially dangerous image attachments" setting in relation to this mod.
o Resolved issue where correct JPEG Quality value was not always being stored in database.




Rock Lee (https://www.simplemachines.org/community/index.php?action=profile;u=322597) : Thanks for updated/new Spanish language files.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Rob Lightbody on May 15, 2018, 05:13:19 AM
Hello!  Its me again.

Something odd... I've changed host (although its very similar technically), and after i did so, every JPG image was white-screening immediately on upload.

I uninstalled this mod, and the memory limit one, and then re-installed the memory limit mod, and then this one (v5.5) and it started working again.

However, if automatic rotate is turned on , I get the white-screen again.  If I turn auto-rotate off, it works.

Manual image rotation works fine, even with a very large 4.5mb 5152x3864 pixels image.

Thanks for any suggestions.

Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on May 15, 2018, 06:44:11 AM
Quote from: The QE2 Story Forum on May 15, 2018, 05:13:19 AM
Hello!  Its me again.

Something odd... I've changed host (although its very similar technically), and after i did so, every JPG image was white-screening immediately on upload.

I uninstalled this mod, and the memory limit one, and then re-installed the memory limit mod, and then this one (v5.5) and it started working again.

However, if automatic rotate is turned on , I get the white-screen again.  If I turn auto-rotate off, it works.

Manual image rotation works fine, even with a very large 4.5mb 5152x3864 pixels image.

Thanks for any suggestions.
Have you tried increasing the memory allocated via the "Image Processing Memory Limit" mod? 

I'm using 256 for one forum and 512 for another (it's a higher spec shared server) and neither have issues with auto-rotation.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Rob Lightbody on May 15, 2018, 09:04:01 AM
Quote from: GL700Wing on May 15, 2018, 06:44:11 AM
Quote from: The QE2 Story Forum on May 15, 2018, 05:13:19 AM
Hello!  Its me again.

Something odd... I've changed host (although its very similar technically), and after i did so, every JPG image was white-screening immediately on upload.

I uninstalled this mod, and the memory limit one, and then re-installed the memory limit mod, and then this one (v5.5) and it started working again.

However, if automatic rotate is turned on , I get the white-screen again.  If I turn auto-rotate off, it works.

Manual image rotation works fine, even with a very large 4.5mb 5152x3864 pixels image.

Thanks for any suggestions.
Have you tried increasing the memory allocated via the "Image Processing Memory Limit" mod? 

I'm using 256 for one forum and 512 for another (it's a higher spec shared server) and neither have issues with auto-rotation.

Hi.. Thanks.  It was at 128, I've tried 256 and 512 but it still does the same thing.  As soon as I turn off "automatically rotate" it lets it upload, and I can then still manually rotate it no problem (in fact it does it instantly)..
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Rob Lightbody on May 15, 2018, 10:41:04 AM
Also seeing this error lots of times, but only for guests :-

https://www.theqe2story.com/forum/index.php?topic=6455.0
8: Undefined variable: mp
File: /home/theqesto/public_html/forum/Sources/Class-exifReader.php
Line: 1201
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on May 16, 2018, 08:18:21 AM
Quote from: The QE2 Story Forum on May 15, 2018, 09:04:01 AM
Hi.. Thanks.  It was at 128, I've tried 256 and 512 but it still does the same thing.  As soon as I turn off "automatically rotate" it lets it upload, and I can then still manually rotate it no problem (in fact it does it instantly)..
Have you tried adjusting the settings in the php.ini file for the forum?

These are the settings I'm using for the forum on the higher spec shared server:
memory_limit = 512M
post_max_size = 64M
upload_max_filesize = 64M

Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on May 16, 2018, 08:27:13 AM
Quote from: The QE2 Story Forum on May 15, 2018, 10:41:04 AM
Also seeing this error lots of times, but only for guests :-

https://www.theqe2story.com/forum/index.php?topic=6455.0
8: Undefined variable: mp
File: /home/theqesto/public_html/forum/Sources/Class-exifReader.php
Line: 1201
I've never seen that error and I'm unable to reproduce it but if you make the following change to line 1201 of ./Sources/Class-exifReader.php it should fix the problem:

Find:
$this->ImageInfo['h']["customRendered"] = ($mp == 0) ? 'Normal Process' : ($mp == 1 ? 'Custom Process' : 'Reserved');

Replace With:
$this->ImageInfo['h']["customRendered"] = (!isset($mp) || $mp == 0) ? 'Normal Process' : ($mp == 1 ? 'Custom Process' : 'Reserved');

The change basically makes 'Normal Process' the default value (and this is actually the default value for "customRendered") if '$mp" has not already been defined.

If you can test/confirm this fix I'll include it in the next version.

Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Rob Lightbody on May 17, 2018, 06:04:19 PM
HI there,

I did your suggested change a few hours ago, and am not seeing any errors now.

Cheers,

- Rob
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on May 17, 2018, 07:06:46 PM
Quote from: The QE2 Story Forum on May 17, 2018, 06:04:19 PM
I did your suggested change a few hours ago, and am not seeing any errors now.
Thanks - I'll include this fix in the next update.

BTW - You can leave this fix in place until then as it won't generate any errors in relation to ./Sources/Class-exifReader.php when the current version of the mod is uninstalled as it deletes that file completely.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: dougiefresh on May 21, 2018, 11:23:12 PM
Uploaded v5.6 - May 21st, 2018
o Fixed undefined variable error in Class-exifReader.php.




Quote from: GL700Wing on May 16, 2018, 08:27:13 AM
Replace With:
$this->ImageInfo['h']["customRendered"] = (!isset($mp) || $mp == 0) ? 'Normal Process' : ($mp == 1 ? 'Custom Process' : 'Reserved');
I just looked at the code.  Nowhere else is the $mp variable used.  So it should probably read like this:
$this->ImageInfo['h']["customRendered"] = (empty($tmp) ? 'Normal Process' : ($tmp == 1 ? 'Custom Process' : 'Reserved'));
The empty function also catches if the variable isn't defined.  When your statement is replaced with my above code, this SHOULDN'T happen....

I've integrated this change into this version.  Hopefully, it'll help with the mod....  :P ::)
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: dan4ever on June 09, 2018, 01:50:46 PM

Hi


Still getting this error:
8: Undefined offset: 9
Fil: /home4/*****/forum/Sources/Display.php
Rad: 1339


Looks like this:
   list ($id_folder, $real_filename, $file_hash, $file_ext, $id_attach, $attachment_type, $mime_type, $is_approved, $id_member, $proper_rotation) = $smcFunc['db_fetch_row']($request);




Something work around maybe?
have 5.5 will upgrade soon


/Dan
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on June 09, 2018, 08:26:11 PM
Quote from: dan4ever on June 09, 2018, 01:50:46 PM
Still getting this error:
8: Undefined offset: 9
Fil: /home4/*****/forum/Sources/Display.php
Rad: 1339

Looks like this:
   list ($id_folder, $real_filename, $file_hash, $file_ext, $id_attach, $attachment_type, $mime_type, $is_approved, $id_member, $proper_rotation) = $smcFunc['db_fetch_row']($request);

Does line 1325 (or a line very close to this number) in your ./Sources/Display.php look like this?
SELECT a.id_folder, a.filename, a.file_hash, a.fileext, a.id_attach, a.attachment_type, a.mime_type, a.approved, m.id_member, a.proper_rotation
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: dan4ever on June 10, 2018, 07:31:15 AM

Yes!

SELECT a.id_folder, a.filename, a.file_hash, a.fileext, a.id_attach, a.attachment_type, a.mime_type, a.approved, m.id_member, a.proper_rotation


/Dan
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on June 10, 2018, 07:18:53 PM
Quote from: dan4ever on June 10, 2018, 07:31:15 AM
Yes!
Ok - we'll I don't know why those errors are being generated on your forum.  However, given this issue has not been reported previously you could try uninstalling the version you currently have installed (making to sure to fix any uninstall errors) and then install the latest version.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: dougiefresh on October 10, 2018, 11:25:47 AM
Uploaded v5.7 - October 10th, 2018
o No functionality change.
o Updated documentation to point to new website.




@dan4ever:  Sorry to reply so late after your bug report, but did upgrading to v5.6 solve your issue?
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: TourFL on November 02, 2018, 09:16:31 AM
Hello!

I just installed the mod and it seems to work very well. All my forums members (and me) are very grateful for that evolution ;D

But I get followings errors in my logs since I installed:

8: Undefined index: thumb_hash
File: /xxx/web/Sources/Display.php
Line: 1762

8: Undefined index: thumb_folder
File: /xxx/web/Sources/Display.php
Line: 1762

8: Undefined index: thumb_name
File: /xxx/web/Sources/Display.php
Line: 1762

Apparently, it is generated when I post a new picture. Any idea what could cause this?

Thanks a lot!
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: TourFL on November 08, 2018, 08:47:28 AM
Update:
Errors are not created only with the posting of images, but also viewing some pages with attached images (didn't find out yet what kind).
So I get 100+ errors relative to that mod everyday  :(

Here is the problematic code (line 1762 is at the getAttachmentFilename call):


        // A proper thumb doesn't exist yet? Create one!
                        if (empty($attachment['id_thumb']) || $attachment['thumb_width'] > $modSettings['attachmentThumbWidth'] || $attachment['thumb_height'] > $modSettings['attachmentThumbHeight'] || ($attachment['thumb_width'] < $modSettings['attachmentThumbWidth'] && $attachment['thumb_height'] < $modSettings['attachmentThumbHeight']))
                         {
                            [....]
                          }
else
    ========>       $thumb_realname = getAttachmentFilename($attachment['thumb_name'], $attachment['id_thumb'], $attachment['thumb_folder'], false, $attachment['thumb_hash']);

// Get timestamp for thumbnail image:
$time = !empty($thumb_realname) && file_exists($thumb_realname) ? filemtime($thumb_realname) : false;


I'm not sure if a previous installation of the mod didn't uninstall well and messed up the file.
Could anybody post how the code should look like in this part of the file? I run with SMT 2.0.15

Thanks in advance for any help!
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: dougiefresh on November 09, 2018, 07:44:46 PM
@TourFL:  Can you attach your Sources/Display.php so that I can see what is going on here?
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: dougiefresh on November 09, 2018, 10:04:05 PM
@TourFL:  Never mind, I see what is happening.....  Let me fix the issue....
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Denny O on December 10, 2018, 06:11:13 PM
Dougiefresh,

I know you are busy with all that you do here and about life in general, is the new version about ready to come out?
I'm recently appointed the Admin for our website using SMF 2.0.15 | SMF © 2017, Simple Machines XHTML RSS WAP2

My people need a way to post pics that is stupid proof for old fishermen that have no tech savvy. This seems to be the ticket, isit?

I would like to upload this to our site sometime soon as this is a slower time for posting traffic due to the change between soft water and not quite yet hard water.

I will await your response before I up load the latest version of this mod.

Thanks for your work!
Denny O
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: petewadey on December 16, 2018, 09:11:09 AM
First of all, thanks for a great mod.
A couple of questions
1. Even though I have the "Keep backup of original image file when resizing" box unchecked, I'm getting a new attachments folder, preREI in my file manager. Is this normal? I wasn't expecting to see that.
2. In my original attachment file, a lot of attachments are duplicated with temp, or tmp after the name. I can't say I noticed it before using the mod, so not saying it has anything to do with it, just asking. If it is this mod, is it ok to delete one or the other, as the size of my attachment file has almost doubled.
Thanks
Pete
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: TourFL on December 18, 2018, 04:45:39 AM
Hello Dougiefresh!
Any news on the problem with the error logs? I can still send you my Display.php if it helps  ;)

Thanks!
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: landyvlad on February 06, 2019, 06:07:21 AM
Is the mod 2.1 RC1 compatible?

I assume it is BUT i want to be sure before proceeding. Thanks.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: dougiefresh on June 23, 2019, 12:27:14 AM
Uploaded v5.8 - June 22nd, 2019
o Added support for SMF 2.1 RC2.
o Removed support for SMF 2.1 Beta 3.
o SMF 2.0: Fixed undefined index errors in Sources/Display.php.




@TourFL: I think this version should fix the error(s) you reported back a while ago.  Apologees about the length of time between your report and this version's release.  Please let me know if this version fixes the issues you found.  Thanks!

@Denny O:  Apologees about the length of time between your inguiry and this version's release.  This SHOULD work.  Please let me know if you find anything with this version.  Thanks!

@petewadey:  You're welcome.  Off the top of my head, I don't know the answers to the questions being posed, as I was minimally involved in the 5.x series of this mod.  I will endeavor to get you an answer to your questions ASAP!

@landyvlad:  It never safe to assume that any mod that works without issue on a previous beta or RC will work with the next version of SMF.  I missed the RC1 release, and making each mod compatible with it.  However, as of this version, this mod is compatible with RC2.  I hope this helps you.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: dougiefresh on June 23, 2019, 05:58:52 AM
@landyvlad:  I just want to add that once SMF 2.1 goes gold, mods will generally work with minimal modification between versions.  What I mean is mods written for 2.1 SHOULD work on 2.1.1, but it is never safe to assume something written for 2.1 Betas will work on RCs, or on Gold. 

Most of my mods haven't required much modification between these versions, but some require major help to get them to work properly.  Pure hook-based mods sometimes require zero effort to make work in RC2.

I'm also finding that functions that worked in SMF 2.1 Beta 3 work slightly different in RC2 (which added to my fustration until I realized what was happening, and then fustration until I figured out how to make it work as expected)....
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Denny O on June 25, 2019, 01:15:15 AM
dougiefresh,

I did not want to bug you so I did await your response.
Many Thanks my hard working friend! I will see how it turns out here.

Thank You!
Denny O
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: TourFL on July 02, 2019, 05:30:53 AM
Thanks for the update  :)
Unfortunately, the problem is still here (same messages, at the same file/line)

Installation of version 5.8 went smoothly, just had a small conflict on the post.php file with the Inline Attachement module, but it was easily solved manualy.

I attach you my display.php file  ;)
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: TigerAnt on July 26, 2019, 10:39:34 AM
The mod needs to be updated so it will work on php 7.2 without error. it works well on 7.1 but not 7.2. I have it installed on 2.1 RC 2.

error:

Error
Type of error: Undefined_vars
Error message: 8: Undefined index: imiyf_txt
File: /home/djradios/public_html/Sources/Load.php
Line: 2392
URL of page causing the error: https://djradiosoundstation.com/index.php?/music-network/811-izgatnizo/friends
Backtrace information
#0: smf_error_handler()
Called from /home/djradios/public_html/Sources/Load.php on line 2392
#1: loadTheme()
Called from /home/djradios/public_html/index.php on line 191
#2: smf_main()
Called from /home/djradios/public_html/index.php on line 151
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Arantor on July 26, 2019, 11:05:25 AM
That's a different error message, relating to a different mod.

The 7.2 issue is the need to replace uses of create_function.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: TigerAnt on July 26, 2019, 12:34:03 PM
Type of error: General
Error message: 8192: Function create_function() is deprecated
File: /home/djradios/public_html/Sources/ManageAttachments.php
Line: 664
URL of page causing the error: https://djradiosoundstation.com/index.php?action=admin;area=manageattachments;sa=browse
Backtrace information
#0: smf_error_handler()
Called from /home/djradios/public_html/Sources/ManageAttachments.php on line 664
#1: BrowseFiles()
Called from /home/djradios/public_html/Sources/Subs.php on line 5095
#2: call_helper()
Called from /home/djradios/public_html/Sources/ManageAttachments.php on line 86
#3: ManageAttachments()
Called from /home/djradios/public_html/Sources/Admin.php on line 512
#4: AdminMain()
Called from /home/djradios/public_html/index.php on line 151
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: TigerAnt on July 26, 2019, 02:59:10 PM
Quote from: Arantor on July 26, 2019, 11:05:25 AM
That's a different error message, relating to a different mod.

The 7.2 issue is the need to replace uses of create_function.
Sorry I posted the wrong error, here is the right one above.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: TigerAnt on July 26, 2019, 04:26:02 PM
(Update) I had added a mod to 2.1 RC 2, (Automatic Attachment Rotation (and Resize) I removed the mod by deleting it and I noticed that an error still existed. The error goes away when you change the PHP back from 7.2 to 7.1. While in 7.2 every time you clicked on any of these (Browse files: > Attachments | Resize Existing Images | Avatars | Thumbnails) it would create a new error.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Arantor on July 26, 2019, 04:29:43 PM
Deleting mods doesn't remove them, it just removes your ability to uninstall them first.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: TigerAnt on July 26, 2019, 04:43:38 PM
Now that comment went way over my head lol. If I install the mod, are you telling me by uninstalling it, does not delete it from my site?
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Aleksi "Lex" Kilpinen on July 26, 2019, 04:52:42 PM
Delete and uninstall are two different functions. Delete removes the package, uninstall removes the functionality.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: TigerAnt on July 26, 2019, 04:56:14 PM
Quote from: Aleksi "Lex" Kilpinen on July 26, 2019, 04:52:42 PM
Delete and uninstall are two different functions. Delete removes the package, uninstall removes the functionality.
Thank you, I wasn't aware of that!
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: landyvlad on July 29, 2019, 02:47:07 AM
Thanks Dougie !
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: amygil on August 27, 2019, 03:33:40 PM
Thanks for creating this great mod. I have 3 Dougiefresh Mods installed on my forum and they are all very much appreciated.

That said, I just installed the latest SMF release candidate (SMF 2.1 RC2) along with the latest Automatic Attachment Rotation mod (v5.8) and I'm getting a few errors that I thought you might want to know about.

1. I get two errors when anyone visits my Forum's help page:

Type of error: General
Hook call: function "AutoRotation_LoadHelp" in file /path/to/myforum could not be called.
https://forumdomain.com/index.php?action=help

and
Type of error: General
The callable AutoRotation_LoadHelp could not be called.
https://forumdomain.com/index.php?action=help


2. I get an error when anyone visits a page that has an image on it (I think this has been mentioned before but not since the latest release is out)

Type of error: Undefined
8: Undefined variable: proper_rotation
https://forumdomain.com/index.php?action=dlattach;topic=194.0;attach=165;image;ts=1514734086
/path/to/myforum/Sources/ShowAttachments.php (Line 151)


Line 151 of ShowAttachments.php looks like this
if (!$proper_rotation && (isset($_REQUEST['type']) && $_REQUEST['type'] != 'avatar'))

3. My iPhone images are not getting rotated automatically at all. I suspect this is due to changes they made to their file format around iOS 11. The images are now stored as HEIC images and converted to jpeg on upload. I tried uploading both an Avatar and an Attachment and both came out sideways.

Please let me know how I can help you resolve these issues. Thanks!
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Denny O on August 28, 2019, 04:24:53 PM
I had it loaded on our site earlier this week. I cannot load a jpeg image at all, it kicks me back to a blank page.

One of our other members loaded some rather old pics and seemed fine then he did a new one and it was sideways too, I'm trying to find out the details.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: @rjen on September 06, 2019, 04:11:47 PM
I tried to install the latest version to yesterday's Github version for SMF 2.1, but it has a few install errors now...

Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Rob Lightbody on December 01, 2019, 07:53:33 AM
Hi there,

I am seeing a consistent problem, if anyone tries to rotate an image manually, using an iOS device, the attachment disappears.  It works fine on a MacOS device, or on Android, or Windows.

No error is logged when this happens.

Anyone else seen this?

Thanks,

- Rob
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on December 01, 2019, 06:15:40 PM
Quote from: The QE2 Story Forum on December 01, 2019, 07:53:33 AM
Hi there,

I am seeing a consistent problem, if anyone tries to rotate an image manually, using an iOS device, the attachment disappears.  It works fine on a MacOS device, or on Android, or Windows.

No error is logged when this happens.

Anyone else seen this?

Thanks,

- Rob
I've had that happen too but only on iOS devices and I haven't been able to work out a fix because I can't reproduce the problem on a desktop device ...

Basically, when the manual rotation drop-down is selected on an iOS device the checkbox for the image is cleared (ie, the image is marked for deletion). 

The only workaround I've found is to click the checkbox for the image after I've chosen the rotation (and to double-check it) before I save the post.

Thankfully the auto-rotation feature of this mod works most, if not all, of the time for photos that still have their metadata and I've typically only encountered the issue you reported when correcting the rotation of images in posts that were created before the mod was installed and/or for images that have had their metadata removed.

Finally, I suspect it's specifically an iOS issue because I've used five different browsers on my iPad and the same thing happens with every one.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on December 03, 2019, 06:49:01 AM
Uploaded v5.9 - December 3, 2019
o Per The QE2 Story Forum (https://www.simplemachines.org/community/index.php?topic=544111.msg4039028#msg4039028) - fixed issue specific to iOS (eg, iphones, iPads, etc) of attachments being marked for deletion (ie, checkbox cleared) when rotation dropdown selected while modifying post.



@The QE2 Story Forum - Although the issue you reported (and which I have also encountered) only seems to affect iOS users it was in fact caused by a bug in the mod.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: woolly bugger on December 03, 2019, 02:38:46 PM
Just tried to install 5.9 on my 2.1RC2 dl from github two weeks ago... 11/22

https://github.com/SimpleMachines/SMF2.1/compare/96865d4...release-2.1

getting errors, see attached

Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on December 03, 2019, 05:17:16 PM
Quote from: woolly bugger on December 03, 2019, 02:38:46 PM
Just tried to install 5.9 on my 2.1RC2 dl from github two weeks ago... 11/22

https://github.com/SimpleMachines/SMF2.1/compare/96865d4...release-2.1

getting errors, see attached
The only change I made was to Post.template.php - I'll have to leave it to Dougiefresh to investigate/resolve the issues you are experiencing. 

Also, have you tried installing this mod by itself on a clean 2.1RC2?  If you have and it installs without any errors then the issue you is that one or more of the others mods you've already installed had modified parts of the same code this mod is trying to update.  If this is the case you will need to install this mod manually - see https://wiki.simplemachines.org/smf/Error_in_mod_installation
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Rob Lightbody on December 08, 2019, 06:39:54 AM
Hi,

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

Thanks very much indeed.

- Rob
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: 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

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?
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on January 23, 2020, 04:52:54 AM
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.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: TourFL on January 24, 2020, 03:59:57 AM
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  :-\
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Capion on March 21, 2020, 05:35:37 AM
Thank You for at really great mod ;)

Could You make it handle the images in SMF gallery too?
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Sir Osis of Liver on September 09, 2020, 12:45:07 PM
If  anyone's still supporting this mod, per this topic (https://www.simplemachines.org/community/index.php?topic=574679.0) 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.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on September 09, 2020, 06:11:07 PM
Quote from: Sir Osis of Liver on September 09, 2020, 12:45:07 PM
If  anyone's still supporting this mod, per this topic (https://www.simplemachines.org/community/index.php?topic=574679.0) 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.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on September 09, 2020, 09:08:30 PM
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 (https://www.simplemachines.org/community/index.php?topic=574679.0) you referred to.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: 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?
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: 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 ...

As per the information in this post (https://www.simplemachines.org/community/index.php?topic=546041.0) - 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 (https://custom.simplemachines.org/mods/index.php?mod=4111) 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.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Sir Osis of Liver on September 09, 2020, 11:01:10 PM
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.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on September 10, 2020, 06:59:37 AM
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 (https://custom.simplemachines.org/mods/index.php?mod=4111) 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!
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Sir Osis of Liver on September 10, 2020, 04:53:09 PM
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 (https://custom.simplemachines.org/mods/index.php?mod=2206) 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.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on September 10, 2020, 07:09:38 PM
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 (https://custom.simplemachines.org/mods/index.php?mod=2206) to resize with good results.
I also used to use the Resize Attached Images (https://custom.simplemachines.org/mods/index.php?mod=2206) 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).





Title: Re: Automatic Attachment Rotation (and Resize)
Post by: forumovod on September 28, 2020, 11:55:56 PM
Automatic Attachment Rotation (and Resize)
the mod indicates problems at installation in 2.1 RC3
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on September 29, 2020, 01:24:42 AM
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 (https://www.simplemachines.org/community/index.php?topic=544111.0) this mod has not been verified to work with 2.1 RC3.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: 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 (https://www.simplemachines.org/community/index.php?topic=544111.0) 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
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on September 30, 2020, 02:02:21 AM
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 (https://www.simplemachines.org/community/index.php?topic=544111.0) 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 ...
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: forumovod on September 30, 2020, 08:06:47 PM
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
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on September 30, 2020, 10:11:46 PM
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
(https://www.simplemachines.org/community/index.php?action=dlattach;topic=544111.0;attach=270808;image)
FYI (and just in case you can't work it out): 2.1 RC2 is not the same as 2.1 RC3
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on October 01, 2020, 07:21:34 PM
Uploaded v5.10 - October 2, 2020
o Added option to enable/disable mod via an admin setting.
o Added option to configure PHP memory limit specifically for this mod. (Note: The Image Processing Memory Limit (https://custom.simplemachines.org/mods/index.php?mod=4111) mod is no loner required).
o Added option to configure different JPEG quality and max width/height for specific membergroups (eg, admins, moderators, other regular groups and/or post count based groups).
o Updated and streamlined code for image rotation and resizing processes.
o Removed support for SMF 2.1 (all versions).
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: forumovod on October 01, 2020, 07:43:17 PM
Quote from: GL700Wing on September 30, 2020, 10:11:46 PM
FYI (and just in case you can't work it out): 2.1 RC2 is not the same as 2.1 RC3

FYI (and just in case you can't work it out): https://www.simplemachines.org/community/index.php?topic=544111.msg4069367#msg4069367
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on October 02, 2020, 08:37:58 AM
Uploaded v5.11 - October 2, 2020
o Minor bug fix to V5.10
o Improved integration with Post and PM Inline Attachments (https://custom.simplemachines.org/mods/index.php?mod=3770) mod.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: TourFL on October 20, 2020, 05:23:37 AM
Hello,

I installed the latest versions I still have the problem of unknown thumb_hash/thumb_name/thumb_folder in my error logs
I compared my local display.php file with the official SMF 2.0.17 file and I don't see anything which could interfir with that code, and that line generating the errors has been add by this module.
The module is perfectly installed with no error/conflict

So I checked my database. I see the attachement table has the id_thumb column, but the thumb_hash/thumb_name/thumb_folder are not present. Is this the problem? What are they meant to be created from? Shall I add those columns manually?

Thanks
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on October 20, 2020, 07:06:44 AM
Quote from: TourFL on October 20, 2020, 05:23:37 AM
I installed the latest versions I still have the problem of unknown thumb_hash/thumb_name/thumb_folder in my error logs
I compared my local display.php file with the official SMF 2.0.17 file and I don't see anything which could interfir with that code, and that line generating the errors has been add by this module.
The module is perfectly installed with no error/conflict

So I checked my database. I see the attachement table has the id_thumb column, but the thumb_hash/thumb_name/thumb_folder are not present. Is this the problem? What are they meant to be created from? Shall I add those columns manually?
There are no separate columns in the database for thumb_hash, thumb_name or thumb_folder - these values are derived from the file_hash, filename and id_folder columns respectively.

I am not able to reproduce the issue you've reported when this mod is installed on a new SMF 2.0.17 forum and from what you've described it seems that this mod may not have uninstalled fully/correctly at some stage in the past - please attach a copy of your ./Sources/Display.php file.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: TourFL on October 20, 2020, 07:20:27 AM
Thanks for your help!
Here is the display.php file.

Today I tried a a full verification of the attached files and avatar, using the built-in SMF tool. It corrected some errors, including some attachements with bad parent (?) or wrong size files. We'll see if it helps.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on October 20, 2020, 06:43:02 PM
Quote from: TourFL on October 20, 2020, 07:20:27 AM
Thanks for your help!
Here is the display.php file.
I can't find any issues in your Display.php file in relation to this mod - I can see that you also have the @mention members (https://custom.simplemachines.org/mods/index.php?mod=3860), Last Post From Previous Page (https://custom.simplemachines.org/mods/index.php?mod=4102) and Topic Solved (https://custom.simplemachines.org/mods/index.php?mod=1601) mods installed but even after I installed those mods with this mod I still can't reproduce the issue you reported.

I did, however, notice that you have installed the Last Post From Previous Page (https://custom.simplemachines.org/mods/index.php?mod=4102) mod twice as the code from two different versions is in Display.php - from lines 1201-1206 (older version) and from lines 1207-1216 (more recent version).  I'd suggest that you uninstall the Last Post From Previous Page (https://custom.simplemachines.org/mods/index.php?mod=4102) mod, cleanup Display.php to make sure there is no code from earlier versions left and then install the latest version.

QuoteToday I tried a a full verification of the attached files and avatar, using the built-in SMF tool. It corrected some errors, including some attachements with bad parent (?) or wrong size files. We'll see if it helps.
Given there are no issues in your Display.php file I was going to suggest that you run "Administration Center » Attachments and Avatars » File Maintenance" to resolve any database/file system errors.



Title: Re: Automatic Attachment Rotation (and Resize)
Post by: TourFL on October 21, 2020, 02:53:48 AM
Thanks for analysis, I cleaned the old code from "Last Post From Previous Page"!

This morning I got 83 errors, so the File Maintenance didn't help  :'(

I saw all the errors are coming from:
- search: .../index.php?action=search2;params=XXX
- Showing user posts: Appliquer le filtre: .../index.php?action=profile;area=showposts;u=999
- Posting: .../index.php?action=post;topic=10023.15;last_msg=218212

I could reproduce it my self, if I do a reply on a subject including photos, the reply page will show the last 15 posts. There was 3 images within those messages, I got 9 errors (3 per image)
Same if I show user posts or perform a search, if images are showing in the results, I get 3 errors per image.

However, no problem when I read subjects "normaly". I'll investigate the post.php and search.php to see if they can be the source of the problem
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: TourFL on October 22, 2020, 09:33:17 AM
Can't find anything more :(
I checked post.php, display, subs, post-template, search... found 2-3 mistakes that I corrected, but errors are still here. And from the code search I did, the only references to those are in the display.php file, and introduced by this module.

As mentionned earlier, I pinpointed the cases triggering errors. If I display images by reading messages, it's working fine. But images displayed in seach results, list of user messages, or replying to a post if images are displayed in the last 15 posts showing under the reply box -> 3 errors per image.
Feels like in those cases, the SQL request is not performed before.

I'm no SQL programmer, but I try to understand what's wrong.
In my file, I see the line causing problem is refering to $attachement['thumb_hash']
I found its initialisation:
$attachments = array();
and the SQL request setting the 3 problematic variable just under. Shouldn't be the initialisation of $attachement after the SQL request?
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on October 23, 2020, 02:10:41 AM
Quote from: TourFL on October 22, 2020, 09:33:17 AM
Can't find anything more :(
I checked post.php, display, subs, post-template, search... found 2-3 mistakes that I corrected, but errors are still here. And from the code search I did, the only references to those are in the display.php file, and introduced by this module.
It's possible, with multiple mods installed (and even if all the mods install without any errors), to end up with a situation where unexpected errors occur even when these errors never occur when the mods are installed individually. 

Also, the order in which mods are installed (ie, mod A, mod B, mod C, mod D) can result in errors occurring that don't happen when the mods are installed in a different order (ie, mod B, mod D, mod C, mod A).

If you let me know all the mods you've got installed I'll setup a test SMF 2.0.17 forum and install the latest version of each mod to see if I can reproduce the problem (obviously the forum files wont have any modifications you've made but it will be a start).
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: TourFL on October 23, 2020, 02:35:15 AM
Thanks again! My installed mods:
I'm not sure all of them still exist  :-\
What I suspect, is problem with In Line Attachement (ILA), but my problem is if I switch to an alternative mod (for example yours), syntaxe of attachement will be different and I would have thousands of message to update in order to have everything working again  :(
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: TourFL on October 23, 2020, 04:07:00 AM
I did some more tests, and saw that if I de-activate the automatic rotation in the admin panel, I still get errors. So I tend to think that the 3 actions generating errors (reply, search, list user messages) are not going through your updated SQL request.

On my side I replaced the line generating errors in display.php:
Quote$thumb_realname = getAttachmentFilename($attachment['thumb_name'], $attachment['id_thumb'], $attachment['thumb_folder'], false, $attachment['thumb_hash']);
by some simple tests to avoid those errors:
Quoteif (isset ($attachment['thumb_hash']) )
{
   $thumb_realname = getAttachmentFilename($attachment['thumb_name'], $attachment['id_thumb'], $attachment['thumb_folder'], false, $attachment['thumb_hash']);
}
else
{
   $thumb_realname = "";
}

Just a dirty workaround, but in the end it works as before without generating errors!
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on October 23, 2020, 09:41:13 PM
Quote from: TourFL on October 23, 2020, 02:35:15 AM

  • InLine Attachments   1.2.1
What I suspect, is problem with In Line Attachement (ILA), but my problem is if I switch to an alternative mod (for example yours), syntaxe of attachement will be different and I would have thousands of message to update in order to have everything working again  :(
I installed ILA 1.2.1 (https://www.smfhacks.com/index.php?action=downloads;sa=view;down=186) on a test forum, added some inline attachments, uninstalled ILA 1.2.1 (https://www.smfhacks.com/index.php?action=downloads;sa=view;down=186) and then installed Post and PM Inline Attachments (https://custom.simplemachines.org/mods/index.php?mod=3770) and I can confirm that attachments inserted inline by ILA 1.2.1 (https://www.smfhacks.com/index.php?action=downloads;sa=view;down=186) are also displayed inline by the Post and PM Inline Attachments (https://custom.simplemachines.org/mods/index.php?mod=3770) mod.

There are a number of settings for the the Post and PM Inline Attachments (https://custom.simplemachines.org/mods/index.php?mod=3770) mod that will determine how inline attachments are displayed - you may need to try changing some of these to get the same inline display effect you have now - or to choose something different.

Finally, make sure you backup all the files updated by these mods before you uninstall/install either of them.

Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Sir Osis of Liver on December 30, 2020, 11:50:09 AM
Installed rotation mod in 2.0.17, it's enabled, no dropmenu in reply editor.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on December 30, 2020, 05:57:37 PM
Thanks for reporting this issue - just letting you know I'm away on holidays until 9 January and I'll investigate it when I return.

Quote from: Sir Osis of Liver on December 30, 2020, 11:50:09 AM
Installed rotation mod in 2.0.17, it's enabled, no dropmenu in reply editor.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Sir Osis of Liver on December 30, 2020, 08:49:16 PM
Yarf. :(  I'll see if the auto rotation works.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on December 30, 2020, 10:56:16 PM
Quote from: Sir Osis of Liver on December 30, 2020, 08:49:16 PM
Yarf. :(  I'll see if the auto rotation works.
Haven't had any reports of auto-rotation not working and on all my forums the option to manually rotate images is available when editing/modifying existing posts.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Sir Osis of Liver on December 31, 2020, 04:25:17 PM
Ok, got it working.  Dropmenu doesn't display on initial post, only on Modify.  Looked a little clunky, made a few cosmetic changes.  Nice mod.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on December 31, 2020, 05:10:40 PM
Quote from: Sir Osis of Liver on December 31, 2020, 04:25:17 PM
Ok, got it working.  Dropmenu doesn't display on initial post, only on Modify.
I'm pretty sure that's how it's always been - the idea is for the image to be autorotated when it is uploaded if the EXIF data is available and to allow manual rotation after it has been uploaded - I'll check back through earlier versions when I get home to confirm.

QuoteLooked a little clunky, made a few cosmetic changes.
That change looks great - if you don't mind I'd like to incorporate it in the next release.

QuoteNice mod.
Yeah - Dougiefresh writes nice mods!
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Sir Osis of Liver on December 31, 2020, 05:21:40 PM


sprintf('<select id="orient[%1$d]" name="orient[%1$d]" style="height: 35px; margin: 0 10px 0 15px;">
<option value="1">ROTATE/FLIP IMAGE</option>
<option value="6">' . $txt['img_orientation6'] . '</option>
<option value="8">' . $txt['img_orientation8'] . '</option>
<option value="3">' . $txt['img_orientation3'] . '</option>
<option value="2">' . $txt['img_orientation2'] . '</option>
<option value="4">' . $txt['img_orientation4'] . '</option>
<option value="7">' . $txt['img_orientation7'] . '</option>
<option value="5">' . $txt['img_orientation5'] . '</option>
</select>', $attachment['id']);


Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on December 31, 2020, 05:33:02 PM
Quote from: Sir Osis of Liver on December 31, 2020, 05:21:40 PM

sprintf('<select id="orient[%1$d]" name="orient[%1$d]" style="height: 35px; margin: 0 10px 0 15px;">
<option value="1">ROTATE/FLIP IMAGE</option>
<option value="6">' . $txt['img_orientation6'] . '</option>
<option value="8">' . $txt['img_orientation8'] . '</option>
<option value="3">' . $txt['img_orientation3'] . '</option>
<option value="2">' . $txt['img_orientation2'] . '</option>
<option value="4">' . $txt['img_orientation4'] . '</option>
<option value="7">' . $txt['img_orientation7'] . '</option>
<option value="5">' . $txt['img_orientation5'] . '</option>
</select>', $attachment['id']);
Great - thanks!!

I finished a new version a couple of weeks ago (it has some minor bug fixes/changes) which I've installed on my forums and I'll incorporate this change in the next release.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: @rjen on January 13, 2021, 05:07:36 AM
I am testing witch SMF 2.0.18 (beta testing) on 7.4 and this MOD is throwing some errors when an attachment is uploaded hat is NOT an image...

Errors:

https://test.my-forum.com/index.php?action=post2;start=0;board=26
8: Trying to access array offset on value of type bool
File: /home/deb77453/domains/my-forum.com/public_html/test/Sources/Subs-AutoRotation.php
Line: 514

https://test.my-forum.com/index.php?action=post2;start=0;board=26
8: Trying to access array offset on value of type bool
File: /home/deb77453/domains/my-forum.com/public_html/test/Sources/Subs-AutoRotation.php
Line: 507

https://test.my-forum.com/index.php?action=post2;start=0;board=26
8: Trying to access array offset on value of type bool
File: /home/deb77453/domains/my-forum.com/public_html/test/Sources/Subs-AutoRotation.php
Line: 506

https://test.my-forum.com/index.php?action=post2;start=0;board=26
8: Trying to access array offset on value of type bool
File: /home/deb77453/domains/my-forum.com/public_html/test/Sources/Subs-AutoRotation.php
Line: 505

These are caused by the $info in line 504 not being populated. PHP7.4 does not like that...
This can be fixed by not executing the rotation code if the attachment is not an image...

   // Find out the image dimensions and type and if it's a JPEG image.
   $info = @getimagesize($filename);

File: Subs-AutoRotation.php

Find:

// Find out the image dimensions and type and if it's a JPEG image.
$info = @getimagesize($filename);
$width = $info[0];
$height = $info[1];
$type = $info[2];

// Find out if this image needs to be rotated, reformatted, resized and/or compressed.
$autoRotate = $modSettings['attachment_auto_rotate'];

// If this is a JPEG image find out if it has an EXIF orientation set.
$rotateImage = false;
if ($info['mime'] == 'image/jpeg')
{
$imageExif = @exif_read_data($filename);
if (isset($imageExif['Orientation']) || array_key_exists('Orientation', $imageExif))
$orientation = $imageExif['Orientation'];

if (!empty($orientation))
$rotateImage = in_array($orientation, [2, 3, 4, 5, 6, 7, 8]);
}

// Work out if the image should be reformatted to JPEG.
$reformatImage = $modSettings[$prefix . 'attachment_image_reformat'];
$preferred_format = $type;
// Only GIF and PNG image formats can be retained - all other image formats are converted to JPEG.
if ($reformatImage || ($type != 1 && $type != 3))
$preferred_format = 2;

// Set reformatImage to false if the image format is not changing.
$reformatImage = ($preferred_format == $type ? false : true);

// Work out if the image is being resized.
$resizeImage = AutoRotation_Aspect($width, $height, $prefix, $inAttachmentOtherGroups);

// Work out if the JPEG image should be compressed.
$compressImage = ($preferred_format == 2 && $jpegQuality > 0 && $jpegQuality < 100 ? true : false);

// Nothing to see here - this image doesn't need to be rotated, reformatted, resized and/or compressed.
if (!$rotateImage && !$reformatImage && !$resizeImage && !$compressImage)
return;
// Rotate the image if autoRotate is true, rotateImage is true, and resizeImage is false.
elseif ($autoRotate && $rotateImage && !$resizeImage)
{
AutoRotation_Process($filename, $orientation, $jpegQuality);

// Recheck the file size
$_FILES['attachment']['size'][$index] = filesize($filename);
}
// Rotate, reformat, resize and/or compress the image as required.
elseif (($autoRotate && $rotateImage) || $reformatImage || $resizeImage || $compressImage)
{
// Resize/reformat the image ...
require_once($sourcedir . '/Subs-Graphics.php');
if (resizeImageFile($filename, $filename . '.temp', $width, $height, $preferred_format, $jpegQuality))
{
// Delete the old tmp file and rename the new one.
unlink($filename);
rename($filename . '.temp', $filename);

// Rotate the image if autoRotate is true and rotateImage is true.
if ($autoRotate && $rotateImage)
AutoRotation_Process($filename, $orientation, $jpegQuality);

// Recheck the file size
$_FILES['attachment']['size'][$index] = filesize($filename);

// Change the file suffix to 'jpg' if necessary.
$filename = $_FILES['attachment']['name'][$index];
if ($preferred_format == 2 && strrchr($filename, '.') != '.jpg')
$_FILES['attachment']['name'][$index] = substr($filename, 0, -(strlen(strrchr($filename, '.')))) . '.jpg';
}
}
}


Replace by:

// Find out the image dimensions and type and if it's a JPEG image.
$info = @getimagesize($filename);
if($info) {
$width = $info[0];
$height = $info[1];
$type = $info[2];

// Find out if this image needs to be rotated, reformatted, resized and/or compressed.
$autoRotate = $modSettings['attachment_auto_rotate'];

// If this is a JPEG image find out if it has an EXIF orientation set.
$rotateImage = false;
if ($info['mime'] == 'image/jpeg')
{
$imageExif = @exif_read_data($filename);
if (isset($imageExif['Orientation']) || array_key_exists('Orientation', $imageExif))
$orientation = $imageExif['Orientation'];

if (!empty($orientation))
$rotateImage = in_array($orientation, [2, 3, 4, 5, 6, 7, 8]);
}

// Work out if the image should be reformatted to JPEG.
$reformatImage = $modSettings[$prefix . 'attachment_image_reformat'];
$preferred_format = $type;
// Only GIF and PNG image formats can be retained - all other image formats are converted to JPEG.
if ($reformatImage || ($type != 1 && $type != 3))
$preferred_format = 2;

// Set reformatImage to false if the image format is not changing.
$reformatImage = ($preferred_format == $type ? false : true);

// Work out if the image is being resized.
$resizeImage = AutoRotation_Aspect($width, $height, $prefix, $inAttachmentOtherGroups);

// Work out if the JPEG image should be compressed.
$compressImage = ($preferred_format == 2 && $jpegQuality > 0 && $jpegQuality < 100 ? true : false);

// Nothing to see here - this image doesn't need to be rotated, reformatted, resized and/or compressed.
if (!$rotateImage && !$reformatImage && !$resizeImage && !$compressImage)
return;
// Rotate the image if autoRotate is true, rotateImage is true, and resizeImage is false.
elseif ($autoRotate && $rotateImage && !$resizeImage)
{
AutoRotation_Process($filename, $orientation, $jpegQuality);

// Recheck the file size
$_FILES['attachment']['size'][$index] = filesize($filename);
}
// Rotate, reformat, resize and/or compress the image as required.
elseif (($autoRotate && $rotateImage) || $reformatImage || $resizeImage || $compressImage)
{
// Resize/reformat the image ...
require_once($sourcedir . '/Subs-Graphics.php');
if (resizeImageFile($filename, $filename . '.temp', $width, $height, $preferred_format, $jpegQuality))
{
// Delete the old tmp file and rename the new one.
unlink($filename);
rename($filename . '.temp', $filename);

// Rotate the image if autoRotate is true and rotateImage is true.
if ($autoRotate && $rotateImage)
AutoRotation_Process($filename, $orientation, $jpegQuality);

// Recheck the file size
$_FILES['attachment']['size'][$index] = filesize($filename);

// Change the file suffix to 'jpg' if necessary.
$filename = $_FILES['attachment']['name'][$index];
if ($preferred_format == 2 && strrchr($filename, '.') != '.jpg')
$_FILES['attachment']['name'][$index] = substr($filename, 0, -(strlen(strrchr($filename, '.')))) . '.jpg';
}
}
}
}

Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on January 13, 2021, 05:29:18 AM
Quote from: @rjen on January 13, 2021, 05:07:36 AM
I am testing witch SMF 2.0.18 (beta testing) on 7.4 and this MOD is throwing some errors when an attachment is uploaded that is NOT an image...

<snip>...</snip>

These are caused by the $info in line 504 not being populated. PHP7.4 does not like that...
This can be fixed by not executing the rotation code if the attachment is not an image...

   // Find out the image dimensions and type and if it's a JPEG image.
   $info = @getimagesize($filename);

<snip>...</snip>

@rjen - Many thanks for letting me know about this issue - I have a new version of this mod just about ready to release.

The same code is executed on line 101 of ./Sources/Subs-AutoRotation.php but it is followed by the following check which I'll now add after line 504:
if (!$info)
return false;


I'll also check the other places where getimagesize is used in this mod and if necessary update the code to only continue if the attachment is an image.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: @rjen on January 13, 2021, 05:35:11 AM
There's another change needed in teh inline attachments mod, I'll log that there...

By the way: the updates in the SMF2.0.18 code will require the install for this MOD to be slightly updated for 2.0.18.
Just a heads up for when 2.0.18 gets released...
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on January 13, 2021, 05:42:26 AM
Quote from: @rjen on January 13, 2021, 05:35:11 AM
There's another change needed in teh inline attachments mod, I'll log that there...

By the way: the updates in the SMF2.0.18 code will require the install for this MOD to be slightly updated for 2.0.18.
Just a heads up for when 2.0.18 gets released...
Thanks - I also have a new version of that mod just about ready for release so I think I'll wait until after SMF 2.0.18 has been released so that I make them both compatible with SMF 2.0.18.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: @rjen on January 13, 2021, 05:46:33 AM
Missed this correction, sorry...

   ./Sources/Subs-ResizeExistingImages.php
   Search:
      $context['resize_results'][9999999] = '|' . $txt['resize_images_timeout'] . ' ' . array_sum(explode(' ', microtime())) - array_sum(explode(' ', $time_start));
   Replace:
      $context['resize_results'][9999999] = '|' . $txt['resize_images_timeout'] . ' ' . array_sum((explode(' ', microtime())) - array_sum(explode(' ', $time_start)));
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on January 13, 2021, 05:52:48 AM
Quote from: @rjen on January 13, 2021, 05:46:33 AM
Missed this correction, sorry...

   ./Sources/Subs-ResizeExistingImages.php
   Search:
      $context['resize_results'][9999999] = '|' . $txt['resize_images_timeout'] . ' ' . array_sum(explode(' ', microtime())) - array_sum(explode(' ', $time_start));
   Replace:
      $context['resize_results'][9999999] = '|' . $txt['resize_images_timeout'] . ' ' . array_sum((explode(' ', microtime())) - array_sum(explode(' ', $time_start)));

Noted and changed - thanks!
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: landyvlad on February 02, 2021, 06:22:34 PM
Q: If this mod is uninstalled / deleted will that affect any of the attachments already existing on the forum?
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on February 02, 2021, 07:03:42 PM
Quote from: landyvlad on February 02, 2021, 06:22:34 PM
Q: If this mod is uninstalled / deleted will that affect any of the attachments already existing on the forum?
No - although if you remove the database data (ie, the columns "proper_rotation" and "jpeg_quality" from "smf_attachments") and re-install the mod later on you will lose this information about existing attachments.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on February 02, 2021, 07:29:09 PM
Uploaded v6.00 - February 03, 2021
o Updated to support SMF 2.0.18/PHP 7.4.4 thanks to @rjen - ./Sources/Subs-AutoRotation.php (https://www.simplemachines.org/community/index.php?topic=544111.msg4078185#msg4078185) and ./Sources/Subs-ResizeExistingImages.php (https://www.simplemachines.org/community/index.php?topic=544111.msg4078190#msg4078190).
o Improved layout as per suggestion made by Sir Osis of Liver (https://www.simplemachines.org/community/index.php?topic=544111.msg4077038#msg4077038).
o Added option to enable/disable reformatting/resizing of images using a single setting.
o Added option to enable/disable the use of different resizing options for some membergroups (introduced in V5.10) using a single setting.
o Added option for members who can use different resizing options so they can choose which settings to use (eg, standard or different) when attaching an image to posts or PMs. (See attachment)
o Minor bug fixes.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: petewadey on February 03, 2021, 03:46:55 AM
Hi,
I'm getting the attached failed tests when trying to install the mod? Should I uninstall the previous version first?
Thanks
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on February 03, 2021, 04:14:59 AM
Quote from: petewadey on February 03, 2021, 03:46:55 AM
I'm getting the attached failed tests when trying to install the mod? Should I uninstall the previous version first?

Yes - you should always install the previous version of a mod unless it specifically offers an upgrade option.


I've installed this mod on a fresh install of SMF 2.0.18 and on several forums running SMF 2.0.17 (these forums have between 110 and 140 other mods installed) without encountering any errors during the installation.

The errors you're seeing are most likely caused by the code this mod is trying to change having been changed by one or more other mods you have installed.

You could try uninstalling some of the other mods but you may encounter the same issues when you try and reinstall them - best bet is to use the following instructions: https://wiki.simplemachines.org/smf/Error_in_mod_installation
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: petewadey on February 03, 2021, 04:53:11 AM
Thanks, I've done that and all seems well.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on February 03, 2021, 05:32:08 AM
Quote from: petewadey on February 03, 2021, 04:53:11 AM
Thanks, I've done that and all seems well.
Great - thanks for letting me know!
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: petewadey on February 03, 2021, 05:49:10 AM
I changed the script in the text/x-generic file, but not the application/x-httpd-php file. I have just tried to change that file and get the attached warning?
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: petewadey on February 03, 2021, 10:05:57 AM
Too be a bit more clear, its the php~ file I changed. The error message was on the php file, which I have not yet changed. If that makes sense?
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on February 03, 2021, 04:43:09 PM
Quote from: petewadey on February 03, 2021, 05:49:10 AM
I changed the script in the text/x-generic file, but not the application/x-httpd-php file. I have just tried to change that file and get the attached warning?
When reporting an issue it would be helpful if you also included version of SMF you're using and the name of the file that's throwing the error/you're editing ...

Based on the other code shown in the image you attached it looks like you're using SMF 2.0.17 or earlier and the file you're editing is ./Sources/ManageAttachments.php

Quote from: petewadey on February 03, 2021, 10:05:57 AM
Too be a bit more clear, its the php~ file I changed. The error message was on the php file, which I have not yet changed. If that makes sense?
The '.php~' file is a backup file and when you make manual edits you have to edit the main file (ie, the '.php' file).

Also, you need to type the edit exactly as it's shown (or preferably copy/paste it) - the edit you make must include all the '\' characters shown.

$time = filemtime(getAttachmentFilename($rowData[\'filename\'], $rowData[\'id_attach\'], $rowData[\'id_folder\'], false, $rowData[\'file_hash\']));
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: petewadey on February 03, 2021, 05:04:56 PM
Sorry I wasn't clear enough. It is in fact SMF 2.0.18 I'm using and it is the Sources/ManageAttachments.php that I'm trying to edit. I will try again with the code you have attached. Many thanks
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: petewadey on February 03, 2021, 05:12:22 PM
The code you just posted worked. Thanks.
It differs from the code I tried to use before which was
{
$time = filemtime(getAttachmentFilename($rowData['filename'], $rowData['id_attach'], $rowData['id_folder'], false, $rowData['file_hash']));
$link .= sprintf('%1$s?action=dlattach;topic=%2$d.0;attach=%3$d;ts=%4$d', $scripturl, $rowData['id_topic'], $rowData['id_attach'], $time);
}


Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on February 03, 2021, 05:44:36 PM
Quote from: petewadey on February 03, 2021, 05:12:22 PM
The code you just posted worked. Thanks.
It differs from the code I tried to use before which was <snip>
I'm glad you've got it working although what you've posted doesn't match what is working on my SMF 2.0.17 and SMF 2.0.18 forums - if this mod was already installed when you updated to SMF 2.0.18 it would have prevented the SMF 2.0.18 update from correctly updating that function in ./Sources/ManageAttachments.php.

You can confirm this by checking the full block of code for that function which, with this mod installed, should be as follows:
'function' => function($rowData) use ($modSettings, $context, $scripturl)
{
$link = '<a href="';

// In case of a custom avatar URL attachments have a fixed directory.
if ($rowData['attachment_type'] == 1)
$link .= sprintf('%1$s/%2$s', $modSettings['custom_avatar_url'], $rowData['filename']);

// By default avatars are downloaded almost as attachments.
elseif ($context['browse_type'] == 'avatars')
$link .= sprintf('%1$s?action=dlattach;type=avatar;attach=%2$d', $scripturl, $rowData['id_attach']);

// Normal attachments are always linked to a topic ID.
else
{
$time = filemtime(getAttachmentFilename($rowData['filename'], $rowData['id_attach'], $rowData['id_folder'], false, $rowData['file_hash']));
$link .= sprintf('%1$s?action=dlattach;topic=%2$d.0;attach=%3$d;ts=%4$d', $scripturl, $rowData['id_topic'], $rowData['id_attach'], $time);
}

$link .= '"';

// Show a popup on click if it's a picture and we know its dimensions.
if (!empty($rowData['width']) && !empty($rowData['height']))
$link .= sprintf(' onclick="return reqWin(this.href' . ($rowData['attachment_type'] == 1 ? '' : '+ \';image\'') . ', %1$d, %2$d, true);"', $rowData['width'] + 20, $rowData['height'] + 20);

$link .= sprintf('>%1$s</a>', preg_replace('~&amp;#(\\\\d{1,7}|x[0-9a-fA-F]{1,6});~', '&#\\\\1;', htmlspecialchars($rowData['filename'])));

// Show the dimensions.
if (!empty($rowData['width']) && !empty($rowData['height']))
$link .= sprintf(' <span class="smalltext">%1$dx%2$d</span>', $rowData['width'], $rowData['height']);

return $link;
},
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: petewadey on February 04, 2021, 03:41:16 AM
I checked my Admin log and I definitely installed SMF 2.0.18 before this mod. I have now replaced my code with the one you posted and all seems well. Many thanks
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: @rjen on February 04, 2021, 05:09:57 AM
After installing the new version on 2.0.18 I am missing the Rotate/Flip option when editing posts...

See attachments...
Works in 5.11
Option gone in 6.00
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on February 04, 2021, 08:53:41 AM
Uploaded v6.01 - February 05, 2021
o Reinstated support for co-installation with versions of the Post and PM Inline Attachments (https://custom.simplemachines.org/mods/index.php?mod=3770) mod prior to v7.00 - support was accidentally left out in v6.00 of this mod.  Reported by @rjen (https://www.simplemachines.org/community/index.php?topic=544111.msg4080913#msg4080913).




NOTE: This mod has been designed to work with the Post and PM Inline Attachments (https://custom.simplemachines.org/mods/index.php?mod=3770) mod and although it doesn't matter in which order these mods are installed they must be uninstalled in the reverse order if you need to uninstall/reinstall this mod.  Failure to follow this procedure will result in an incomplete uninstall for both mods.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: @rjen on February 04, 2021, 08:55:13 AM
Ouch... thanks....
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: @rjen on February 04, 2021, 01:59:03 PM
Quote from: GL700Wing on February 04, 2021, 08:53:41 AM
Uploaded v6.01 - February 05, 2021
o Reinstated support for co-installation with versions of the Post and PM Inline Attachments (https://custom.simplemachines.org/mods/index.php?mod=3770) mod prior to v7.00 - support was accidentally left out in v6.00 of this mod.  Reported by @rjen (https://www.simplemachines.org/community/index.php?topic=544111.msg4080913#msg4080913).

I just installed v6.01 of the mod after Post and PM Inline Attachments v7.00, and there is no change: I still cannot rotate existing attachments...
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on February 04, 2021, 10:34:24 PM
Quote from: @rjen on February 04, 2021, 08:55:13 AM
Ouch... thanks....
Yeah - sorry.

It's becoming increasingly challenging to keep these two mods in step with each other to the point that I'm seriously considering merging them into one mod but in such a way that each feature set (ie, Auto Rotate and Inline Attachments) can be enabled/disabled independently.

Quote from: @rjen on February 04, 2021, 01:59:03 PM
I just installed v6.01 of the mod after Post and PM Inline Attachments v7.00, and there is no change: I still cannot rotate existing attachments...
If you let me know which version of SMF you're using and upload your Post.template.php file I'll fix it for you.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on February 05, 2021, 12:55:02 AM
Quote from: GL700Wing on February 04, 2021, 10:34:24 PM
It's becoming increasingly challenging to keep these two mods in step with each other to the point that I'm seriously considering merging them into one mod but in such a way that each feature set (ie, Auto Rotate and Inline Attachments) can be enabled/disabled independently.
Hmph - I've already given up on that idea - with the amount of 'read me' information for each mod it will become too difficult to manage.

I think the approach I'm going to take is to reload v5.11 and then make v6.xx only compatible with v7.xx of the Post and PM Inline Attachments (https://custom.simplemachines.org/mods/index.php?mod=3770) mod (and vice versa) because the installer for each mod is trying to maintain compatibility with reciprocal versions of the other mod that are up to three years old.

Also, one of the challenges I'm trying to deal with with these mods is that they each make changes to the same area of the Post.template.php file and I'd started 'ignoring' errors during installation in order to support multiple older versions of each mod plus the situation where the other mod is not installed.

So - I'm going to completely review the installation process for each of these mods for when they are installed together with the view to eliminating the need to use 'ignore' statements for installation errors in Post.template.php.  However, and even if this is possible, it may become necessary to install these mods in a specific order (and to uninstall them in the reverse order if the mod that was installed first needs to be uninstalled).

I've got a fair bit of work already lined up for next week so it might be a couple of weeks before I can get this worked out for both mods.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: @rjen on February 05, 2021, 02:33:00 AM
Quote from: GL700Wing on February 04, 2021, 10:34:24 PM
Quote from: @rjen on February 04, 2021, 01:59:03 PM
I just installed v6.01 of the mod after Post and PM Inline Attachments v7.00, and there is no change: I still cannot rotate existing attachments...
If you let me know which version of SMF you're using and upload your Post.template.php file I'll fix it for you.

I am on 2.0.18, but I have already made the previous MOD versions 2.0.18 compliant, so I am OK: I will stay on the old versions while you sort out the mods...

Just for your information I am adding the file here, perhaps it will help in you efforts...
It seems that the code from line 515 is missing...
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: @rjen on February 05, 2021, 03:29:52 PM
Find attached the dutch language files updated to the latest version
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on February 06, 2021, 04:21:48 AM
Uploaded v6.02 - February 06, 2021
o Fixed bug that prevented this mod from fully installing with Post and PM Inline Attachments (https://custom.simplemachines.org/mods/index.php?mod=3770) v7.00 - as reported by @rjen (https://www.simplemachines.org/community/index.php?topic=544111.msg4081000#msg4081000).



IMPORTANT NOTE: In order to fully support the Post and PM Inline Attachments (https://custom.simplemachines.org/mods/index.php?mod=3770) mod you must install this mod after you install that mod!!
Also, if you subsequently need to uninstall the Post and PM Inline Attachments (https://custom.simplemachines.org/mods/index.php?mod=3770) mod you must uninstall this mod beforehand.



Many thanks to @rjen for the Dutch language files (https://www.simplemachines.org/community/index.php?topic=544111.msg4081113#msg4081113).
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Rob Lightbody on February 15, 2021, 01:38:29 PM
Hi,

I uninstalled 5.9, which had been working fine.

Installed the 2.0.18 update for SMF (coming from 2.0.17).

And then installed 6.02 version of this mod.

Attaching images now just comes up with a blank screen, and doesn't work.  Turning the mod off in attachment settings fixes the problem.

No error in the error log.

Thanks.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on February 15, 2021, 08:20:31 PM
Quote from: Rob Lightbody on February 15, 2021, 01:38:29 PM
Attaching images now just comes up with a blank screen, and doesn't work.  Turning the mod off in attachment settings fixes the problem.
I've installed v6.02 of mod on a new SMF 2.0.18 forum and also on an SMF 2.0.18 forum that has more than 130 other mods installed I can successfully attach images on both forums.

A blank/white screen can be an indication of insufficient PHP memory for image processing - you can configure the amount of memory this mod can use via the 'The amount of server memory (in megabytes) to allocate to image rotation/resizing. (eg, 128)' option in 'Administration Center > Attachments and Avatars > Attachment Settings'.

Here's the details of an image I attached with this mod:
Image Dimensions: 7680 x 5760
File Size: 6.86Mb

Due to its dimensions the forum needed approximately 256Mb of memory (including the memory the forum was using) in order for auto-rotation and auto-resizing to work (for testing purposes I had no limit for attachment size).

Quote
No error in the error log.
Have you also checked the error_log file in the forum's home directory/folder?
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Rob Lightbody on February 16, 2021, 05:08:47 AM
Thanks for that.

It seems to go pretty immediately to the white page, no matter whether its a small or larger image.  It was set at 128, but I then tried it at various numbers up to 2048 but none worked.

I checked the other error log, and there's nothing relevant in it for the time when I was trying this.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on February 16, 2021, 05:56:40 AM
Quote from: Rob Lightbody on February 16, 2021, 05:08:47 AM
Thanks for that.

It seems to go pretty immediately to the white page, no matter whether its a small or larger image.  It was set at 128, but I then tried it at various numbers up to 2048 but none worked.

I checked the other error log, and there's nothing relevant in it for the time when I was trying this.
PM sent ...
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Rob Lightbody on February 20, 2021, 05:28:58 AM
Quote from: GL700Wing on February 16, 2021, 05:56:40 AM
Quote from: Rob Lightbody on February 16, 2021, 05:08:47 AM
Thanks for that.

It seems to go pretty immediately to the white page, no matter whether its a small or larger image.  It was set at 128, but I then tried it at various numbers up to 2048 but none worked.

I checked the other error log, and there's nothing relevant in it for the time when I was trying this.
PM sent ...

Thank you for your help with this offline, greatly appreciated.

What it appears to have come down to is that by upgrading my PHP level from 5.6.40 to 7.2.34, the modification started working perfectly again.

Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on February 20, 2021, 05:34:47 AM
Quote from: Rob Lightbody on February 20, 2021, 05:28:58 AM
Thank you for your help with this offline, greatly appreciated.

What it appears to have come down to is that by upgrading my PHP level from 5.6.40 to 7.2.34, the modification started working perfectly again.
That's great news - thanks for letting me know!
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Rob Lightbody on March 04, 2021, 05:41:45 AM
Hello, me again.

If I go to Admin > Attachments & Avatars > Browse Files > Resize Existing Images.

Then i click a big file that was uploaded a while ago and click the resize button I'm getting this error :-

Too few arguments to function AutoRotation_Aspect(), 2 passed in /home/theqesto/public_html/forum/Sources/Subs-ResizeExistingImages.php on line 417 and exactly 4 expected


The mod is otherwise operating perfectly.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on March 04, 2021, 06:40:34 AM
Quote from: Rob Lightbody on March 04, 2021, 05:41:45 AM
Hello, me again.

If I go to Admin > Attachments & Avatars > Browse Files > Resize Existing Images.

Then i click a big file that was uploaded a while ago and click the resize button I'm getting this error :-

Too few arguments to function AutoRotation_Aspect(), 2 passed in /home/theqesto/public_html/forum/Sources/Subs-ResizeExistingImages.php on line 417 and exactly 4 expected


The mod is otherwise operating perfectly.
Thanks for letting me know about this bug - I've worked out the fix and I'll upload a new version of the mod shortly.

In the meantime, you can apply the following fix to line 592 of ./Sources/Subs-AutoRotation.php (it won't affect the ability of the mod to be uninstalled as this file is removed completely):

Find:
function AutoRotation_Aspect(&$width, &$height, $prefix, $otherSettings)
Replace With:
function AutoRotation_Aspect(&$width, &$height, $prefix = '', $otherSettings = '')
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Rob Lightbody on March 04, 2021, 11:03:20 AM
That has worked a treat, thank you.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Denny O on May 11, 2021, 11:29:58 PM
I am able to load a 4474.64 kB, 4032x1960 jpeg pic and smaller but unable to load a larger one.
Our site is
SMF 2.0.15 | SMF © 2017, Simple Machines  XHTML RSS WAP2
The mod is
Automatic Attachment Rotation (and Resize)   ver5.8

I can't seem to find a size limit, is there one and if not why might this be a problem?
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on May 12, 2021, 12:59:48 AM
Quote from: Denny O on May 11, 2021, 11:29:58 PM
I am able to load a 4474.64 kB, 4032x1960 jpeg pic and smaller but unable to load a larger one.
Our site is
SMF 2.0.15 | SMF © 2017, Simple Machines  XHTML RSS WAP2
The mod is
Automatic Attachment Rotation (and Resize)   ver5.8

I can't seem to find a size limit, is there one and if not why might this be a problem?
If you are encountering a 'white screen' issue when attempting to upload images with large dimensions (eg, larger than 4032x1960 pixels) this is an indication that more memory is required for processing the image - you will need to either install a later version of this mod (eg, 5.11 or 6.02) or install the Image Processing Memory Limit (https://custom.simplemachines.org/mods/index.php?mod=4111) mod and configure additional memory for image processing.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Denny O on May 17, 2021, 04:59:19 PM
Upgraded our site early this afternoon to 2.0.18 and Automatic Attachment Rotation (and Resize) to 6.02 and seems to be working flawlessly, at this point anyway.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: WolfJ on August 14, 2021, 01:23:02 PM
Sorry to be a bother but just setting up a fresh forum at the moment but seem to have run into a little issue. Even though I've set the attachment tag not to include the message at the end when I test and save the post to test it, it's still adding the msg part at the end adding the topic title on the right side of the image.

Did I do something wrong, I read the read me and did everything it asked. Checked the resizing and it's worked a treat just this one issue.

Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on August 14, 2021, 08:11:41 PM
Quote from: Legosi on August 14, 2021, 01:23:02 PM
Sorry to be a bother but just setting up a fresh forum at the moment but seem to have run into a little issue. Even though I've set the attachment tag not to include the message at the end when I test and save the post to test it, it's still adding the msg part at the end adding the topic title on the right side of the image.

Did I do something wrong, I read the read me and did everything it asked. Checked the resizing and it's worked a treat just this one issue.
I don't think the issue you've reported relates to this mod as it doesn't have any attachment tags associated with it.

Are you able to post a screen capture of the issue you're encountering?
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: WolfJ on August 15, 2021, 04:52:54 AM
Quote from: GL700Wing on August 14, 2021, 08:11:41 PM
Quote from: Legosi on August 14, 2021, 01:23:02 PM
Sorry to be a bother but just setting up a fresh forum at the moment but seem to have run into a little issue. Even though I've set the attachment tag not to include the message at the end when I test and save the post to test it, it's still adding the msg part at the end adding the topic title on the right side of the image.

Did I do something wrong, I read the read me and did everything it asked. Checked the resizing and it's worked a treat just this one issue.
I don't think the issue you've reported relates to this mod as it doesn't have any attachment tags associated with it.

Are you able to post a screen capture of the issue you're encountering?

Sorry. Yeah I posted in the wrong topic, didn't mean to. I found the right topic and I'll post there. Thanks
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: landyvlad on September 07, 2021, 01:10:16 AM
Any plans for this to be updated to be 2.1.x compatible?
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on September 07, 2021, 01:26:07 AM
Quote from: landyvlad on September 07, 2021, 01:10:16 AMAny plans for this to be updated to be 2.1.x compatible?
Almost done for SMF 2.1 RC4 - just finishing extensive testing ...
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on September 22, 2021, 04:01:17 AM
After almost six months of work I'm pleased to announce the next release of this mod ...

Uploaded v6.10 - September 21, 2021
o Added support for SMF 2.1 RC4 (official release only - not GitHub releases).
o Added support for ImageMagick/Imagick image processor.
o Added support for LazyLoad (https://custom.simplemachines.org/mods/index.php?mod=4259) mod.
o Added support for converting 'webp' images to JPG format.
o Added option to increase PHP 'max_input_time' value for processing images.
o Added options for rotating images and thumbnails separately when modifying a message (and for Admins when browsing files via the Admin center) (See attached image).
o Added code to display a thumbnail-sized copy of each attached image (and a smaller version of the real thumbnail if it exists) when editing a message (and for Admins when browsing files via the Admin center).
o Bug fix for issue reported by Rob Lightbody (https://www.simplemachines.org/community/index.php?topic=544111.msg4083730#msg4083730) when manually resizing existing images via "Administration Center >> Attachments and Avatars >> Browse Files >> Resize Existing Images".
o Made some changes in Post.template.php to ensure consistent font sizing when installed with the Post and PM Inline Attachments (https://custom.simplemachines.org/mods/index.php?mod=3770) mod.
o Streamlined process for importing images.
o Consolidated code for resizing images automatically and in batch mode.
o Minor bug fixes.

Zip files containing screen images for SMF 2.0 and SMF 2.1 can also be downloaded with the mod package.


Many thanks once again to @rjen (https://www.simplemachines.org/community/index.php?action=profile;u=287786) and RockLee (https://www.simplemachines.org/community/index.php?action=profile;u=322597) for language translations.

Important Note:
This mod supports the official release of SMF 2.1 RC4 only - it will not be updated to support GitHub releases.  It will be only be updated for SMF 2.1 again after the final release version becomes available.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on September 22, 2021, 11:17:21 PM
Quote from: GL700Wing on September 22, 2021, 04:01:17 AMImportant Note:
This mod supports the official release of SMF 2.1 RC4 only - it will not be updated to support GitHub releases.  It will be only be updated for SMF 2.1 again after the final release version becomes available.
As I had already done most of the work required to support the latest GitHub release of RC4 (ie, 18-Sep-21) I finished developing and testing a compatible release this morning and have now decided to release it to allow people who are testing the GitHub release of SMF 2.1 RC4 to also install and test this mod.

There are now two mod files for version 6.10 of this mod:
Automatic_Attachment_Rotation_and_Resize_v6.10-SMF20-SMF21RC4Official.zip which is compatible with SMF 2.0 and the official release of SMF 2.1 RC4; and
Automatic_Attachment_Rotation_and_Resize_v6.10-RC4GitHub-210918.zip which is compatible with the RC4 GitHub release of 18-Sep-21.

Notes for those using any release of SMF 2.1 RC4: There is an 'Image Rotation' option at the bottom of the 'More' dropdown tab shown in the message body for accessing the manual image rotation feature.  Also, and unlike with SMF 2.0, it is not possible to add more attachments when using the 'Image Rotation' option to edit a message.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: @rjen on September 23, 2021, 04:14:35 PM
There is a small issue in this package: Automatic_Attachment_Rotation_and_Resize_v6.10-RC4GitHub-210918.zip

For reasons unknown to me the file ResizeExistingImages.english.php has a text string OUTSIDE the php tags. This "IDS" string is showing up in the header of the forum after install.
Pretty sure that should be removed...

IDS<?php
/***********************************************************************************************************
* ResizeExistingImages.english.php - English language file                                                 *
************************************************************************************************************
* This mod is licensed under the 2-Clause BSD License, which can be found here:                            *
* https://opensource.org/licenses/BSD-2-Clause                                                           *
************************************************************************************************************
* Copyright (c) 2016-2021 Douglas Orend, 2019-2021 Kathy Leslie                                            *
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on September 23, 2021, 05:49:11 PM
Quote from: @rjen on September 23, 2021, 04:14:35 PMThere is a small issue in this package: Automatic_Attachment_Rotation_and_Resize_v6.10-RC4GitHub-210918.zip

For reasons unknown to me the file ResizeExistingImages.english.php has a text string OUTSIDE the php tags. This "IDS" string is showing up in the header of the forum after install.
Pretty sure that should be removed...
Thanks for letting me know - I've fixed ResizeExistingImages.english.php in both copies of the mod.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: @rjen on October 05, 2021, 02:50:22 AM
Latest version in SMF2.1. Calling SMF help page gives two errors:

https://test2.fjr-club.nl/index.php?action=help
Type of error: General
Error message
Hook call: function "AutoRotation_LoadHelp" in file /home/deb77453/domains/fjr-club.nl/public_html/test2 could not be called.

https://test2.fjr-club.nl/index.php?action=help 
Type of error: General
Error message
The callable AutoRotation_LoadHelp could not be called.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on October 05, 2021, 05:09:21 AM
Uploaded v6.11 - October 05, 2021
Per @rjen (https://www.simplemachines.org/community/index.php?msg=4099986) - fixed SMF 2.1 bug by removing reference to AutoRotation_LoadHelp hook.


Thanks to @rjen for reporting this issue.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: txcas on January 30, 2022, 02:44:32 PM
I loaded v.6.11 on SMF 2.1 RC4. When I try to resize and/or reformat existing images I get he following error:
Undefined index: resize_images_timeout
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on January 31, 2022, 05:01:00 PM
Quote from: txcas on January 30, 2022, 02:44:32 PMI loaded v.6.11 on SMF 2.1 RC4. When I try to resize and/or reformat existing images I get he following error:
Undefined index: resize_images_timeout
Thanks for letting me know - which file was this error reported for?

I'm currently away on holidays until late March and won't be able to release a new version of this mod with a fix until then.  However, I'll check the code and see if there is a manual fix you can apply now.


Edit: Okay - I've confirmed a text string is missing but this is not the main problem: it seems a processing timeout is occurring - are you using the batch resize/reformat function (ie, Administration Center » Attachments and Avatars » File Maintenance  » 'Automatic Attachment Rotation (and Resize)' Mod - Batch Resize/Reformat Existing Images)?
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: txcas on February 01, 2022, 03:20:32 PM
Quote from: GL700Wing on January 31, 2022, 05:01:00 PM
Quote from: txcas on January 30, 2022, 02:44:32 PMI loaded v.6.11 on SMF 2.1 RC4. When I try to resize and/or reformat existing images I get he following error:
Undefined index: resize_images_timeout
Thanks for letting me know - which file was this error reported for?

I'm currently away on holidays until late March and won't be able to release a new version of this mod with a fix until then.  However, I'll check the code and see if there is a manual fix you can apply now.


Edit: Okay - I've confirmed a text string is missing but this is not the main problem: it seems a processing timeout is occurring - are you using the batch resize/reformat function (ie, Administration Center » Attachments and Avatars » File Maintenance  » 'Automatic Attachment Rotation (and Resize)' Mod - Batch Resize/Reformat Existing Images)?
Thanks. Yes I am using the batch resize/format function.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on February 02, 2022, 04:37:02 AM
Quote from: txcas on February 01, 2022, 03:20:32 PMThanks. Yes I am using the batch resize/format function.
Okay - it seems you have some images that are taking too long to convert and they are causing the batch conversion to fail.

Please ensure you are following the instructions in the readme:
The forum should be configured as follows prior to commencing batch resizing:
o Admin => Configuration => Server Settings => General => Enable Maintenance Mode should be enabled.
o Admin => Configuration => Security and Moderation => General => Disable administration security should be disabled.
o Admin => Forum => Posts and Topics => Topic Settings => Number of posts per page in a topic page should be configured to between 15 and 25 via (make a note of the current value).
o Admin => Forum => Attachments and Avatars => Attachment Settings - Maximum size per attachment, Reformat non-JPEG images to JPEG, JPEG quality factor, Maximum width of attached images and Maximum height of attached images should be configured.
o Admin => Forum => Attachments and Avatars => File Maintenance => Attachment Integrity Check should be run and issues corrected


If the problem persists you could try using the Resize/Reformat Existing Images option in Administration Center » Attachments and Avatars » Browse Files to process small groups of files.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: sts_pro on February 06, 2022, 06:31:38 AM
First of all thank you for the great mod!

I just started using it and facing one issue: manual thumbnail rotation for existing attachments is not working. I tried both IT and TO modes: image rotation happening without any issues every time, however, thumbnail does not rotate.
Could it be an issue with some settings on my side?
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: landyvlad on February 09, 2022, 07:18:17 PM
@GL700Wing I have this mod installed on 2.0.19.

I see its noted as compatible with 2.1RC4

With the release now of 2.1.0 is it compatible for use with no further changes necessary?
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on February 11, 2022, 02:38:57 AM
Quote from: landyvlad on February 09, 2022, 07:18:17 PM@GL700Wing I have this mod installed on 2.0.19.

I see its noted as compatible with 2.1RC4

With the release now of 2.1.0 is it compatible for use with no further changes necessary?
No idea and I won't be able to find out for a while as I'm currently at the southern most pub of our southern most state and I won't be home for a month or so after which I have a couple of weeks of motorcycling planned ...

34CE2349-F6A6-44DA-9251-1C16F3145332.jpeg

Title: Re: Automatic Attachment Rotation (and Resize)
Post by: sts_pro on February 12, 2022, 11:32:17 PM
Quote from: sts_pro on February 06, 2022, 06:31:38 AMFirst of all thank you for the great mod!

I just started using it and facing one issue: manual thumbnail rotation for existing attachments is not working. I tried both IT and TO modes: image rotation happening without any issues every time, however, thumbnail does not rotate.
Could it be an issue with some settings on my side?
Revoking my question :) Mod is working as expected, it was a problem on my side 👍
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: evgeniyk on February 13, 2022, 08:25:39 AM
Quote from: landyvlad on February 09, 2022, 07:18:17 PM@GL700Wing I have this mod installed on 2.0.19.

I see its noted as compatible with 2.1RC4

With the release now of 2.1.0 is it compatible for use with no further changes necessary?
It is not working with 2.1.1. Just tried.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Pyrhel on February 16, 2022, 04:43:21 AM
This is one of the most helpful mods I had on the previous version. I hope it will be patched soon.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: gevv on February 25, 2022, 11:58:15 AM
SMF 2.1.1 update canceled :) 

Quote from: Pyrhel on February 16, 2022, 04:43:21 AMThis is one of the most helpful mods I had on the previous version. I hope it will be patched soon.

+1000

@dougiefresh Thanks
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: pmmGarak on February 26, 2022, 06:00:32 AM
I wish the error message on install was somewhat more telling, I have no idea where to look for the problem - GL700wing seems to have no time in the near future... In a forum with lots of non-tech, smartphone photography people, things go really fast towards blown storage quotas without this mod...
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on February 26, 2022, 07:38:43 AM
Quote from: Pyrhel on February 16, 2022, 04:43:21 AMThis is one of the most helpful mods I had on the previous version. I hope it will be patched soon.
I know lots of people are waiting for an update to this mod for 2.1.x and I will create one as soon as I can. 

However, I'm currently away from home on holidays (first time in three years I've been able to get away for more than a couple of weeks) and I won't be home until mid March.  Obviously, and until such time as I have access to my development and test environments (and the internet - I love remote area travelling/camping - most days I have only limited access to mobile/cell phone networks and the internet and you're only getting this reply because today is one of those days!), I don't know how much work is involved in updating the mod so I cannot commit to a release date of a new version.


Quote from: gevv on February 25, 2022, 11:58:15 AM@dougiefresh Thanks
Just letting you know I now maintain this mod - as far as I can tell @dougiefresh has not been active here for almost three years ...


Quote from: pmmGarak on February 26, 2022, 06:00:32 AM... GL700wing seems to have no time in the near future...
If by 'near future' you mean tomorrow or next week (and probably next month) you're correct.  However, and as I have already indicated (https://www.simplemachines.org/community/index.php?msg=4110522), I will be able to work on an update for 2.1.x in early April ...
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: pmmGarak on February 27, 2022, 02:18:10 AM
Quote from: GL700Wing on February 26, 2022, 07:38:43 AMIf by 'near future' you mean tomorrow or next week (and probably next month) you're correct.  However, and as I have already indicated (https://www.simplemachines.org/community/index.php?msg=4110522), I will be able to work on an update for 2.1.x in early April ...

Just to make it clear: I was just spreading the information you gave somewhere else. No critique or pressure, I know quite well how some people can expect volunteers to work quicker and harder than payed folks. And most only learn if ever they try doing something for free others might find useful.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on February 27, 2022, 06:04:46 AM
Quote from: pmmGarak on February 27, 2022, 02:18:10 AMJust to make it clear: I was just spreading the information you gave somewhere else. No critique or pressure, I know quite well how some people can expect volunteers to work quicker and harder than payed folks. And most only learn if ever they try doing something for free others might find useful.
No problem - I just wasn't sure that you were aware of my current situation ...
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on February 27, 2022, 05:39:25 PM
@evgeniyk, @Pyrhel, @gevv, @pmmGarak, etc ...

Just wondering if any of you have tried to install (using emulation mode) and/or use the GitHub version of this mod that I created for 2.1 RC4 (ie, AARR_v6.11-RC4GitHub-210918.zip) - I created this version to work with some 2.1 code changes that were made after RC4 was released ...

70F3FFCD-50F8-4F2C-8211-C36E0A1AE447.jpeg

Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Pyrhel on February 28, 2022, 02:30:08 AM
I've just installed it and in some topics an error occurs:

QuoteAutoRotation_Resize FAILED for "xxx/forum/attachments/10021_04984bee5f70492d0add95ee3a6662888cf7f5e3.dat" - the original image file has been restored.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on February 28, 2022, 02:38:33 AM
Quote from: Pyrhel on February 28, 2022, 02:30:08 AMI've just installed it and in some topics an error occurs:

QuoteAutoRotation_Resize FAILED for "xxx/forum/attachments/10021_04984bee5f70492d0add95ee3a6662888cf7f5e3.dat" - the original image file has been restored.
Try disabling the 'Resize, compress and/or reformat existing images when messages are displayed' option ...
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Pyrhel on February 28, 2022, 04:45:08 AM
Yup, I did it once I went through the topics with attachments, posted after the update to resize all of the 3-4MB images. Now everything seems OK.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: gevv on February 28, 2022, 11:29:32 AM
Quote from: GL700Wing on February 27, 2022, 05:39:25 PM@evgeniyk, @Pyrhel, @gevv, @pmmGarak, etc ...

Just wondering if any of you have tried to install (using emulation mode) and/or use the GitHub version of this mod that I created for 2.1 RC4 (ie, AARR_v6.11-RC4GitHub-210918.zip) - I created this version to work with some 2.1 code changes that were made after RC4 was released ...

70F3FFCD-50F8-4F2C-8211-C36E0A1AE447.jpeg



Using emulation mode  AARR_v6.11-SMF20-SMF21RC4Official.zip

Untitled 2.png


Where can I download the github version? AARR_v6.11-RC4GitHub-210918.zip
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on February 28, 2022, 03:57:47 PM
Quote from: gevv on February 28, 2022, 11:29:32 AMUsing emulation mode AARR_v6.11-SMF20-SMF21RC4Official.zip
...
The issues with installing this version of the mod on 2.1.x have already been reported ...

QuoteWhere can I download the github version? AARR_v6.11-RC4GitHub-210918.zip
From the same place you downloaded AARR_v6.11-SMF20-SMF21RC4Official.zip - it's the package above this one  (shown inside the red box in the image below) ...
6DC19833-A423-4F51-AECD-4C600354F0FF.jpeg
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: @rjen on March 16, 2022, 05:53:26 AM
One more note for the next version:

occasionally this error is logged...

https://www.fjr-club.nl/index.php?action=post;msg=373541;topic=27731.0
/home/deb77453/domains/fjr-club.nl/public_html/Themes/default/Post.template.php (Regel 339) 

Errortype: Ondefined
Error:
8: Undefined index: imageAttachments
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on March 20, 2022, 11:14:52 PM
Uploaded v6.12 - March 21, 2022
o Added support for SMF 2.1.x.
o Removed support for SMF 2.1 RC4.
o SMF 2.1: Per @rjen (https://www.simplemachines.org/community/index.php?msg=4116471) - undefined index error for 'imageAttachments' in ./Themes/default/Post.template.php.
o No changes for SMF 2.0


Thanks to @rjen for reporting this issue.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on March 21, 2022, 06:23:47 AM
Quote from: sts_pro on February 06, 2022, 06:31:38 AMFirst of all thank you for the great mod!

I just started using it and facing one issue: manual thumbnail rotation for existing attachments is not working. I tried both IT and TO modes: image rotation happening without any issues every time, however, thumbnail does not rotate.
Could it be an issue with some settings on my side?
@sts_pro - this issue hasn't been reported by anyone else and it could be a browser caching issue - have you tried clearing your browser cache after rotating thumbnails to see if they display correctly?

Also, and if you're still having this issue, please let me know which version of SMF you are using.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on March 21, 2022, 06:27:28 PM
Quote from: GL700Wing on March 21, 2022, 06:23:47 AM
Quote from: sts_pro on February 06, 2022, 06:31:38 AMFirst of all thank you for the great mod!

I just started using it and facing one issue: manual thumbnail rotation for existing attachments is not working. I tried both IT and TO modes: image rotation happening without any issues every time, however, thumbnail does not rotate.
Could it be an issue with some settings on my side?
@sts_pro - this issue hasn't been reported by anyone else and it could be a browser caching issue - have you tried clearing your browser cache after rotating thumbnails to see if they display correctly?

Also, and if you're still having this issue, please let me know which version of SMF you are using.
@sts_pro - I've done some more testing and found the cause of the issue you reported - after an image/thumb is rotated I change the timestamp back to the original timestamp and because of this most browsers use the cached version of the image/thumb.  I'll fix this in the next release but in the meantime clearing the browser cache should result in the updated image/thumb being shown.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: mucknet on March 22, 2022, 05:08:36 AM
Hi @GL700Wing  -
I have a very old installation, upgraded over the years. I recently upgraded to 2.1.1. I don't have any other Mods, and I'm using the default Theme. The Mod install went well without any major errors. the only test that failed was the "./Sources/PersonalMessage.php" test. I don't know why it failed. Permissions were correct.


The attachment options are showing as expected in the admin console. But when I try to upload an image in a post, I don't see any resizing, or orientation options like the screenshots show. I just see the standard attachment UI.

I had the same results on both 2.0.19 and 2.1.1. I originally tried 2.0.19, and then restored from backup, and tried 2.1.1 when I couldn't make it work on 2.0.19. Both times the "./Sources/PersonalMessage.php" test failed, I could see the admin options, but couldn't resize images during posting/uploading.
I plan on staying on 2.1.1 now that I'm on it.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on March 22, 2022, 07:44:09 AM
Quote from: mucknet on March 22, 2022, 05:08:36 AMHi @GL700Wing  -
I have a very old installation, upgraded over the years. I recently upgraded to 2.1.1. I don't have any other Mods, and I'm using the default Theme. The Mod install went well without any major errors. the only test that failed was the "./Sources/PersonalMessage.php" test. I don't know why it failed. Permissions were correct.
@mucknet - Changes to "./Sources/PersonalMessage.php" are only relevant if you also have the PM Attachments mod installed.  That said, I'll fix the next version to ignore all errors for "./Sources/PersonalMessage.php".

QuoteThe attachment options are showing as expected in the admin console. But when I try to upload an image in a post, I don't see any resizing, or orientation options like the screenshots show. I just see the standard attachment UI.
1.  Image resizing happens automatically when you save a post with an uploaded image (options are only shown for SMF 2.0 if you have configured different options for some membergroups and you have one of those membergroups as your Primary membergroup - for SMF 2.1 information is shown indicating the JPEG quality and maximum width/height that will be used);
3.  If uploaded JPEG images have the orientation EXIF information in their metadata they will be rotated automatically when the post is saved; and
2.  The option to manually rotate images (and now thumbs) has only ever been shown when you edit an existing message.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: mucknet on March 22, 2022, 03:43:29 PM
Quote from: GL700Wing on March 22, 2022, 07:44:09 AM1.  Image resizing happens automatically when you save a post with an uploaded image (options are only shown for SMF 2.0 if you have configured different options for some membergroups and you have one of those membergroups as your Primary membergroup - for SMF 2.1 information is shown indicating the JPEG quality and maximum width/height that will be used);
3.  If uploaded JPEG images have the orientation EXIF information in their metadata they will be rotated automatically when the post is saved; and
2.  The option to manually rotate images (and now thumbs) has only ever been shown when you edit an existing message.


Thanks. That's really helpful. I've confirmed it is indeed working as expected then. Images are getting resized when they upload, which is the thing I cared about. I tried some images that need rotation, and they weren't auto rotated, but I'm not to worried about that. It's probably a use case I am not familiar with. The image resize was the main thing I was after. I'm actually happy there's no additional user facing UI for image resize/rotate because I can experiment with other themes, without worrying about messing this feature up.

Thanks for the great mod. Have a good one.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: gevv on March 22, 2022, 04:21:03 PM
Thanks @GL700Wing
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: mucknet on March 24, 2022, 01:06:32 PM
Hi @GL700Wing -- Would you consider adding an option to this mod to remove privacy related exif data? (ie: GPS data) I looked for another mod to do this, but don't see an option. I tried the "extensive security checks" option, but I couldn't find a single image I have that would upload without getting an error, and I couldn't find any documentation about what it actually does.


P.S. I had ASS-U-ME'd that the "Re-encode potentionally dangerous image attachments" would remove exiff data, but I was clearly wrong.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on March 25, 2022, 12:17:25 AM
Quote from: mucknet on March 24, 2022, 01:06:32 PMWould you consider adding an option to this mod to remove privacy related exif data? (ie: GPS data)
Sure - although having already looked into what's involved it'll probably be easier to remove all EXIF data (with the exception of colour profile stuff if iMagick is used) from JPEG images

QuoteP.S. I had ASS-U-ME'd that the "Re-encode potentionally dangerous image attachments" would remove exiff data, but I was clearly wrong.
That's core SMF code and I don't know which image attachments are considered to be potentially dangerous ...
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: FrizzleFried on March 27, 2022, 12:53:43 PM
One of my users has a question....

Quote2) When I rotate images using the cool new rotate image feature on my PC it works great. But if I go look at that same post on my phone, it is still sideways there.

...is this a bug?  I do not do mobile personally so I can't test it myself.

Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on March 27, 2022, 05:51:19 PM
Quote from: FrizzleFried on March 27, 2022, 12:53:43 PMOne of my users has a question....

Quote2) When I rotate images using the cool new rotate image feature on my PC it works great. But if I go look at that same post on my phone, it is still sideways there.

...is this a bug?  I do not do mobile personally so I can't test it myself.


It's a browser caching issue which I have a workaround for in the next release - see https://www.simplemachines.org/community/index.php?msg=4117126

In the meantime, if the user clears the browser cache for the forum on the affected computer/device the rotated image/thumbnail will be correctly displayed.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Sir Osis of Liver on March 30, 2022, 10:18:16 PM
Installed this on a 2.0.19 forum in php 7.4.  Doesn't rotate all sideways pics off phones.  Used it once before and vaguely remember that if mod doesn't detect EXIF coding it displays option to manually rotate image.  That's not happening.

n/m, I see how it works.  Have to post the image first, if it posts sideways you have to 'Modify', then it displays select menu to rotate it and repost.

Sideways pics attached.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on April 22, 2022, 12:14:20 AM
Version v6.12 - v6.13 - April 22, 2022
o Per sts_pro (https://www.simplemachines.org/community/index.php?msg=4109723) - fixed caching issue of latest image/thumbnail not always being displayed by browser after being rotated.
o Per mucknet (https://www.simplemachines.org/community/index.php?msg=4117428) - added option to remove EXIF data from JPEG files.
o Fixed issue of non-JPEG images not being converted to JPEG if 'Reformat non-JPEG images to JPEG' option was enabled.
o Added support to enable members of Additional Membergroups membergroup IDs to use different resizing options which were introduced for Primary Membergroup and Post Count Based Group membergroup IDs in V5.10.
o SMF 2.1: Reinstated image/thumbnail view for rotating images while editing a message (accidentally disabled in v6.12).
o SMF 2.0: Added mod upgrade options for v6.10, v6.11 and v6.12.
o SMF 2.1: Added mod upgrade options for v6.12.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: @rjen on April 22, 2022, 05:47:45 PM
Just installed the mod on SMF2.1 and I still do not see the option to manually rotate images when editing posts..

SMF 2.1: Reinstated image/thumbnail view for rotating images while editing a message (accidentally disabled in v6.12)

I can rotate and resize from the filemanager in the admin screen, but not when posting or editing posts. Am I missing something?

2022-04-22_234641.jpg

I also noticed some errors in the dutch translation... find attached an update...

AutoRotation.dutch.php

Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on April 22, 2022, 07:18:15 PM
Quote from: @rjen on April 22, 2022, 05:47:45 PMJust installed the mod on SMF2.1 and I still do not see the option to manually rotate images when editing posts..

SMF 2.1: Reinstated image/thumbnail view for rotating images while editing a message (accidentally disabled in v6.12)

I can rotate and resize from the filemanager in the admin screen, but not when posting or editing posts. Am I missing something?
For SMF 2.1 I couldn't work out how to add the manual rotate options to the standard message edit window so I added a 'Image Rotation' option to the 'More ...' drop-down menu instead (it openly appears for messages that have image attachments).

FFFDD20E-C36C-4D7E-AD4E-965FC3A42800.jpeg

Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on April 27, 2022, 02:19:50 AM
Version v6.14 - April 27, 2022
o Per @rjen (https://www.simplemachines.org/community/index.php?msg=4121579) - updated Dutch language files for Auto Rotation.
o Fixed 'Undefined index: thumb_mime' error reported by FrizzleFried (https://www.simplemachines.org/community/index.php?msg=4121552).


Notes
For SMF 2.0 forums using versions 6.10 through 6.13 there are upgrade options to version 6.14 - it is not necessary to uninstall these versions (ie, 6.10 through 6.13) beforehand.

For SMF 2.1 forums using versions 6.12 or 6.13 there are upgrade options to version 6.14 - it is not necessary to uninstall these versions (ie, 6.12 or 6.13) beforehand.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: FrizzleFried on April 27, 2022, 08:08:36 AM
Interested in these "upgrade options" so I don't have to uninstall.  How does that work exactly?  Just install over the top of the old?
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on April 27, 2022, 09:28:45 AM
Quote from: FrizzleFried on April 27, 2022, 08:08:36 AMInterested in these "upgrade options" so I don't have to uninstall.  How does that work exactly?  Just install over the top of the old?
Not very many mods use the upgrade option because it is quite a bit more work for a mod developer to setup and test but if the upgrade process does not encounter any issues during the installation phase it makes the process of upgrading a mod much quicker and easier than having to uninstall and reinstall a mod (especially if one or both of these processes involves manual file edits).

I've done a lot of work and testing in relation to the upgrade process for this mod because either the changes to core SMF files between one version and a later version were only minor, because only the core mod files (eg, ./Sources/Subs-AutoRotation.php, ./Sources/Subs-ResizeExistingImages.php, and/or language files) needed to be updated, or sometimes it was a bit of both ...


Upgrade Process
1. Upload mod file
1.Upload.jpg

2. Click on 'Browse Packages' to see if there is an 'Upgrade' option
2.BrowsePackages.jpg

3. If there is an upgrade path from the currently installed version to the version you just uploaded you will see the 'Upgrade' option
3.Upgrade.jpg

4.  Click on the 'Upgrade' option and, if no errors are reported, click on 'Install Now'
4.InstallNow.jpg

If any installation errors are reported you must resolve these by either making the manual file edits required or by uninstalling the currently installed version and installing the version you just uploaded.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: FrizzleFried on April 27, 2022, 09:46:16 AM
Holy smokes... i've been using SMF for well over a decade now... my last forum was a mod nightmare with TONS AND TONS of mods... and I have NEVER ONCE come across a situation where there was an "upgrade" button available.

> Mind Blown <

NOW... I wonder how many times over those (literally) hundreds of mods there WOULD have been if I had not uninstalled the mod prior to even attempting to upload the new...

Thank you for the detailed explanation!
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on April 27, 2022, 09:55:40 AM
Quote from: FrizzleFried on April 27, 2022, 09:46:16 AMHoly smokes... i've been using SMF for well over a decade now... my last forum was a mod nightmare with TONS AND TONS of mods... and I have NEVER ONCE come across a situation where there was an "upgrade" button available.

> Mind Blown <

NOW... I wonder how many times over those (literally) hundreds of mods there WOULD have been if I had not uninstalled the mod prior to even attempting to upload the new...

Thank you for the detailed explanation!

I've been using SMF for almost 15 years, I have three forums with between 110 and 140 mods each (only a handful of which I've written) and I've only ever seen one mod with an upgrade option (and I used that to teach myself how to implement the upgrade option) ...

'tis a rare beast because it takes more time and effort for a mod developer to implement an upgrade option than the simpler uninstall/install path ...
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Arantor on April 27, 2022, 10:07:17 AM
I've written 100+ mods for SMF in the last 13 years. I implemented upgrade once, the whole experience was so awful I never attempted it again.

Kudos to you for keeping the faith.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: FrizzleFried on April 27, 2022, 10:20:55 AM
One last dumb question... I assume I can DELETE the old version now... but I wanted to confirm that assumption before just doing it.

:D

Title: Re: Automatic Attachment Rotation (and Resize)
Post by: sah62 on April 27, 2022, 03:44:03 PM
I just installed this mod on a forum running SMF 2.0.19 and I noticed multiple errors like these in the error log:

https://www.mysite.com/smf/index.php?topic=81046.0
2: touch(): Utime failed: Operation not permitted
File: /var/www/mysite/smf/Sources/Subs-AutoRotation.php
Line: 1180

https://www.mysite.com/smf/index.php?topic=81046.0
2: touch(): Utime failed: Operation not permitted
File: /var/www/mysite/smf/Sources/Subs-AutoRotation.php
Line: 613

Any thoughts on the cause? I'm thinking it's a file permission/ownership issue, but how can I eliminate the errors?
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on April 27, 2022, 07:00:19 PM
Quote from: FrizzleFried on April 27, 2022, 10:20:55 AMOne last dumb question... I assume I can DELETE the old version now... but I wanted to confirm that assumption before just doing it.
Yep - go for it!

You don't need the older version(s) because if you uninstall the mod the end result in terms of the core SMF files and hook calls in the database will be the exactly same as if you hadn't used an upgrade option (ie, the uninstall process will reverse all the code changes the currently installed version of the mod would have made if the install process had been used - it is not a downgrade).
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on April 27, 2022, 10:20:04 PM
Quote from: sah62 on April 27, 2022, 03:44:03 PMAny thoughts on the cause? I'm thinking it's a file permission/ownership issue, but how can I eliminate the errors?
It is a file permission/ownership issue and you can suppress the error messages by inserting @ before each of the six 'touch' commands in ./Sources/Subs-AutoRotation.php.

Find:
touch(
Replace with
@touch(
Making this change won't prevent you form uninstalling or upgrading this version of the mod in the future and I'll fix this issue in the next release.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: FrizzleFried on May 10, 2022, 10:35:33 AM
It appears this mod will need a small edit to be compatible with 2.1.2... I am getting a single error..


Code(Find) Select

id_thumb, attachment_type, mime_type, approved, id_msg
Code(Add After) Select
, proper_rotation
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on May 10, 2022, 11:04:29 AM
Quote from: FrizzleFried on May 10, 2022, 10:35:33 AMIt appears this mod will need a small edit to be compatible with 2.1.2... I am getting a single error..
Yep - I'm already working on it!!
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on May 10, 2022, 10:13:08 PM
Version v6.15 - May 11, 2022
o Added support for SMF 2.1.2


Note: No changes for SMF 2.0.x, SMF 2.1.0, or SMF 2.1.1
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: gevv on May 11, 2022, 02:44:03 AM
Thanks @GL700Wing
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on May 25, 2022, 11:16:32 PM
Version v6.16 - May 26, 2022
o SMF 2.1: Fixed bug reported by voom (https://www.simplemachines.org/community/index.php?msg=4126312) and woolly bugger (https://www.simplemachines.org/community/index.php?msg=4124219) that was causing a blank edit box to display when modifying a message that quoted another message.


Notes:
No changes for SMF 2.0.x
Upgrade option for v6.13, v6.14 and v6.15
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: WolfJ on August 20, 2022, 05:31:37 PM
I get this error when I try to resize an image

Too few arguments to function AutoRotation_Aspect(), 2 passed in /home/wolfj/public_html/Sources/Subs-ResizeExistingImages.php on line 417 and exactly 4 expected
Anyone know a fix?
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on August 20, 2022, 09:24:51 PM
Quote from: WolfJ on August 20, 2022, 05:31:37 PMI get this error when I try to resize an image

Too few arguments to function AutoRotation_Aspect(), 2 passed in /home/wolfj/public_html/Sources/Subs-ResizeExistingImages.php on line 417 and exactly 4 expected
Anyone know a fix?
@WolfJ - This issue was reported in March 2021 (https://www.simplemachines.org/community/index.php?msg=4083730) and was fixed in subsequent releases starting in September 2021 - I strongly recommend that you update to the latest version but if you don't want to do this you can apply a manual fix (https://www.simplemachines.org/community/index.php?msg=4083732) (this won't affect the ability of the mod to be subsequently uninstalled as this file is removed completely).

Title: Re: Automatic Attachment Rotation (and Resize)
Post by: WolfJ on August 20, 2022, 10:02:10 PM
Quote from: GL700Wing on August 20, 2022, 09:24:51 PM
Quote from: WolfJ on August 20, 2022, 05:31:37 PMI get this error when I try to resize an image

Too few arguments to function AutoRotation_Aspect(), 2 passed in /home/wolfj/public_html/Sources/Subs-ResizeExistingImages.php on line 417 and exactly 4 expected
Anyone know a fix?
@WolfJ - This issue was reported in March 2021 (https://www.simplemachines.org/community/index.php?msg=4083730) and was fixed in subsequent releases starting in September 2021 - I strongly recommend that you update to the latest version but if you don't want to do this you can apply a manual fix (https://www.simplemachines.org/community/index.php?msg=4083732) (this won't affect the ability of the mod to be subsequently uninstalled as this file is removed completely).




Thanks for your response. Yeah, I was still using 6.02. Ever since they updated to SMF 2.1 I saw some mods were no longer available so I kind of started hoarding them. I applied the manual fix but then decided to update anyway to rule out any more issues.

Thank you again!  ;)
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: cortez on September 03, 2022, 08:41:44 AM
Thanks for this excellent mod, any ideas for this on SMF 2.1.2 and PHP 7.4.28

Type of error
General
Error message
8: copy(): write of 8192 bytes failed with errno=14 Bad address
File
/home/autobusi/public_html/forum/Sources/Subs-AutoRotation.php
Line
603
URL of page causing the error
https://autobusi.org/forum/index.php?topic=22812.585

#0: smf_error_handler()
Called from unknown on line -1
#1: copy()
Called from /home/autobusi/public_html/forum/Sources/Subs-AutoRotation.php on line 603
#2: AutoRotation_ResizeExisting()
Called from /home/autobusi/public_html/forum/Sources/Subs-Attachments.php on line 1276
#3: loadAttachmentContext()
Called from /home/autobusi/public_html/forum/Sources/Display.php on line 1495
#4: prepareDisplayContext()
Called from /home/autobusi/public_html/forum/Themes/default/Display.template.php on line 256
#5: template_main()
Called from /home/autobusi/public_html/forum/Sources/Load.php on line 2760
#6: loadSubTemplate()
Called from /home/autobusi/public_html/forum/Sources/Subs.php on line 4155
#7: obExit()
Called from /home/autobusi/public_html/forum/index.php on line 194
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on September 03, 2022, 08:54:02 AM
Quote from: cortez on September 03, 2022, 08:41:44 AMThanks for this excellent mod, any ideas for this on SMF 2.1.2 and PHP 7.4.28

Type of error
General
Error message
8: copy(): write of 8192 bytes failed with errno=14 Bad address
File
/home/autobusi/public_html/forum/Sources/Subs-AutoRotation.php
Line
603
URL of page causing the error
https://autobusi.org/forum/index.php?topic=22812.585

#0: smf_error_handler()
Called from unknown on line -1
#1: copy()
Called from /home/autobusi/public_html/forum/Sources/Subs-AutoRotation.php on line 603
#2: AutoRotation_ResizeExisting()
Called from /home/autobusi/public_html/forum/Sources/Subs-Attachments.php on line 1276
#3: loadAttachmentContext()
Called from /home/autobusi/public_html/forum/Sources/Display.php on line 1495
#4: prepareDisplayContext()
Called from /home/autobusi/public_html/forum/Themes/default/Display.template.php on line 256
#5: template_main()
Called from /home/autobusi/public_html/forum/Sources/Load.php on line 2760
#6: loadSubTemplate()
Called from /home/autobusi/public_html/forum/Sources/Subs.php on line 4155
#7: obExit()
Called from /home/autobusi/public_html/forum/index.php on line 194
Would you please provide information on which version of the mod you're using and how to reproduce this error - thanks.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: cortez on September 03, 2022, 09:41:33 AM
Mod is 6.16, regarding specific action - no idea, if you go to URL, that specific thread page is from 2018 so maybe it is trying to do something with existing images.

Similar to this, also very old thread:
Type of error
General
Error message
8: Trying to access array offset on value of type bool
File
/home/autobusi/public_html/forum/Sources/Subs-AutoRotation.php
Line
483
URL of page causing the error
https://autobusi.org/forum/index.php?topic=620.0
Backtrace information
#0: smf_error_handler()
Called from /home/autobusi/public_html/forum/Sources/Subs-AutoRotation.php on line 483
#1: AutoRotation_DisplayDownload()
Called from /home/autobusi/public_html/forum/Sources/Subs-Attachments.php on line 1272
#2: loadAttachmentContext()
Called from /home/autobusi/public_html/forum/Sources/Display.php on line 1495
#3: prepareDisplayContext()
Called from /home/autobusi/public_html/forum/Themes/default/Display.template.php on line 256
#4: template_main()
Called from /home/autobusi/public_html/forum/Sources/Load.php on line 2760
#5: loadSubTemplate()
Called from /home/autobusi/public_html/forum/Sources/Subs.php on line 4155
#6: obExit()
Called from /home/autobusi/public_html/forum/index.php on line 194
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on September 03, 2022, 05:53:35 PM
Quote from: cortez on September 03, 2022, 09:41:33 AMMod is 6.16, regarding specific action - no idea, if you go to URL, that specific thread page is from 2018 so maybe it is trying to do something with existing images.
I'm wondering if the issue may have to do with missing image attachments - please run the
Administration Center >> Attachments and Avatars >> File Maintenance >> Attachment Integrity Check
to check the integrity and sizes of attachments and filenames listed in the database and, if necessary, fix any errors it encounters.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Volker S on September 15, 2022, 09:21:12 AM
I have install the AddOn on my testforum - and nothing happend. Here comes my install-screens.

Installscreen_01 (http://www.jollauser.de/diverses/resize_install_01.png)
Installscreen_02 (http://www.jollauser.de/diverses/resize_install_02.png)

Setup of your AddOn: Link (http://www.jollauser.de/diverses/resize_setup.png)

Before upload a Image: Empty post (http://www.jollauser.de/diverses/resize_empty_post.png)
After upload a 1,1 MB Image: Try to upload (http://www.jollauser.de/diverses/resize_try_1.1MB-Picture.png)

I have seen no Error. You can try at your own. My Testforum is: https://www.forum.jeepzone.de/index.php
Testaccount: test / test

SMF-Version: 2.1.2 PHP-Version: 7,4 and 8.0 (The result is the same)
Here my installed Mods: Link (http://www.jollauser.de/diverses/SMF_Test_Mods.png)
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on September 15, 2022, 10:33:50 AM
@Volker S

The image has to be uploaded before it can be resized so you need to set the values of the "Max attachment size per post" and "Max size per attachment" settings to a large enough value (eg, maybe 7Mb or 8Mb for photos taken using smartphones) to allow the image to be uploaded.

AARR-1.jpg

Also, newly attached images will not be resized until the post/message is saved.

As per the following example using the default values for the mod an image that was 6.4Mb when it was uploaded was reduced to 123Kb when it was saved.

AARR-2.jpg

AARR-3.jpg

AARR-4.jpg   
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Volker S on September 15, 2022, 11:24:46 AM
Yes, it was clearly a misunderstanding on my part. I didn't notice that your addon worked after the upload. Thanks for your help. Nice Addon
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: dodos26 on September 17, 2022, 11:55:57 AM
You can add permission to see image attachments for guests.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on September 17, 2022, 08:07:12 PM
Quote from: dodos26 on September 17, 2022, 11:55:57 AMYou can add permission to see image attachments for guests.
@dodos26 - There is already a standard permission for this (although it applies to all attachment types) and it can be applied to individual membergroups and/or boards.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: dodos26 on September 18, 2022, 06:07:51 AM
Read what I am asking again --___--


That "although it applies to all attachment types" is not THAT "add permission to see image attachments for guests"
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on September 18, 2022, 06:19:17 AM
Quote from: dodos26 on September 18, 2022, 06:07:51 AMRead what I am asking again --___--


That "although it applies to all attachment types" is not THAT "add permission to see image attachments for guests"
OK - fair enough but you didn't indicate that you already knew there was a permission for all attachment types.

That said, what you're asking for is outside the scope of what this mod was designed to do (ie, this mod has nothing to do with how, when or where attachments are displayed).

Finally, I don't appreciate the way you typed your previous response - I actually consider it to be quite rude and I won't be providing you with any further assistance.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: dodos26 on September 18, 2022, 06:27:44 AM
The way your mental denial is amazing. You create logical error due to illogical reading and then blame someone for your mistakes.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Diego Andrés on September 18, 2022, 09:34:22 AM
Quote from: dodos26 on September 18, 2022, 06:27:44 AMThe way your mental denial is amazing. You create logical error due to illogical reading and then blame someone for your mistakes.

Surely is not that fact that you're are requesting features unrelated to this mod?
Who is she blaming? There's no "per type" control in the attachments system.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: elexx on October 02, 2022, 06:26:32 AM
I wanted to make the suggestion that a function that not only rotates a single image that has been posted for a long time, but also reduces it, would also be a great function. I read the help again and found that it already exists: "Manual Resizing of Existing Images"  8)  It might be great to have this item available in the Rotate/Flip menu as well.
Thank you for the extremely helpful addon!
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on October 02, 2022, 06:26:56 PM
Quote from: elexx on October 02, 2022, 06:26:32 AMI wanted to make the suggestion that a function that not only rotates a single image that has been posted for a long time, but also reduces it, would also be a great function. I read the help again and found that it already exists: "Manual Resizing of Existing Images"  8)  It might be great to have this item available in the Rotate/Flip menu as well.
Thank you for the extremely helpful addon!
Have you tried enabling the "Resize, reformat and/or compress existing images when they are displayed" option?
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: sam666 on October 05, 2022, 01:16:10 PM
Major change introduced in v6.00
o - Support for SMF 2.0.18 and PHP 7.4.

Will 2.0.19 and PHP8.0 be supported in the near future?
Many thanks for keeping this mod supported.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on October 09, 2022, 11:06:52 PM
Quote from: sam666 on October 05, 2022, 01:16:10 PMWill 2.0.19 and PHP8.0 be supported in the near future?
Many thanks for keeping this mod supported.
Not sure - I don't know what's involved in adding support for these versions.

I'm currently away on holidays so I'll look into to this when I have time after I return (hopefully mid-late November).
Title: Automatic Attachment Rotation (and Resize) php problems
Post by: Rheingauner on October 25, 2022, 11:21:57 AM
We have some problems with your mod under PHP 7.4.32, PHP 8.0 and 8.1.1. Under "PHP 7.4.3 by OS vendor" your mod works great.

OS = Ubuntu 20.xx (latest updates are installed) with plesk-panel, SMF-Version 2.1.2

Under PHP 7.4.32, PHP 8.0 and 8.1.1 there are no changes in the picture size when we change the quality for example from 70 to 50, with "PHP 7.4.3 by OS vendor".

There are serious differences in file sizes between php 7.4.3 and the other versions.

Sorry for my bad english.

Kind regards Rheingauner

Filename ending with _50 or _70 means the quality setting
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on October 26, 2022, 04:33:04 AM
Quote from: Rheingauner on October 25, 2022, 11:21:57 AMWe have some problems with your mod under PHP 7.4.32, PHP 8.0 and 8.1.1. Under "PHP 7.4.3 by OS vendor" your mod works great.

OS = Ubuntu 20.xx (latest updates are installed) with plesk-panel, SMF-Version 2.1.2

Under PHP 7.4.32, PHP 8.0 and 8.1.1 there are no changes in the picture size when we change the quality for example from 70 to 50, with "PHP 7.4.3 by OS vendor".

There are serious differences in file sizes between php 7.4.3 and the other versions.

Sorry for my bad english.

Kind regards Rheingauner

Filename ending with _50 or _70 means the quality setting

Which image converter extension are you using - GD or iMagick?

Also, when you switch between the different versions of PHP are you ensuring that the GD and/or iMagick extensions are enabled?

The reason I'm asking is because it is the image converter that determines the final file size and what the resized image looks like - all the mod does is use the image converter you've configured in the mod (ie, GD by default if it is enabled and iMagick if the extension is enabled in PHP  and the associated option is enabled in the mod).

Finally, I haven't tested this mod with PHP 8.x so I really have no idea how the GD and/or iMagick image converter extensions process images.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Rheingauner on October 26, 2022, 08:49:10 AM
Under "PHP 7.4.3 by OS vendor" is only GD working, iMagick is not selectable. iMagick and GD are always enabled with the other PHP Versions. If iMagick ist disabled the filesize is nearly by the original jpg size.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on October 26, 2022, 07:38:41 PM
Quote from: Rheingauner on October 26, 2022, 08:49:10 AMUnder "PHP 7.4.3 by OS vendor" is only GD working, iMagick is not selectable. iMagick and GD are always enabled with the other PHP Versions. If iMagick ist disabled the filesize is nearly by the original jpg size.

Given that the resizing works correctly with "PHP 7.4.3 by OS vendor" it seems there is an issue with the implementation of the PHP GD/iMagick extensions in your other operating system and unfortunately I can't help you with that.

I suggest that you ask for help from the relevant Ubuntu/Plesk support communities.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: dodos26 on November 27, 2022, 08:00:04 AM
Quote from: dodos26 on September 17, 2022, 11:55:57 AMYou can add permission to see image attachments for guests.

The solution in case someone came across the same question publication (https://www.simplemachines.org/community/index.php?topic=584313.0).


Code block removed by mod author because, and as the author of this post has previously been advised (https://www.simplemachines.org/community/index.php?msg=4135087), this mod has nothing to do with how, when or where image attachments are displayed.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: SeaChaser on February 27, 2023, 01:15:27 PM
Is there an upgrade to 6.16 needed for SMF 2.1.3?

I am getting the installation error below:

(https://www.simplemachines.org/community/proxy.php?request=http%3A%2F%2Fwww.arimaowners.com%2Fgallery%2F17%2F1-270223101500.jpeg&hash=6ec314e9ab45006df7f64f83f6c91e5a4682a342)
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on February 28, 2023, 06:07:34 AM
Quote from: SeaChaser on February 27, 2023, 01:15:27 PMIs there an upgrade to 6.16 needed for SMF 2.1.3?
Possibly but I'm currently away on holidays and won't get an opportunity to investigate this issue and/or update the mod for another month or so.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: landyvlad on March 21, 2023, 12:41:09 AM
Cool really looking forward to the update for compatibility with 2.2.3 and on.

(because as stated it doesn't work for 2.1.3 even if stating to install emulating 2.1.2)

I hope you're enjoying your holiday mate :)
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: petewadey on March 21, 2023, 09:04:58 AM
None of my older attachments are loading, and on investigation in my cpanel file manager, I notice the attachments no longer loading have been compressed, so are no longer jpg's but are ( gzip compressed data, from Unix, last modified: Thu Dec 30 01:18:29 2021, max speed )
Is this possibly anything to do with this mod?
   
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Diego Andrés on March 21, 2023, 09:46:36 AM
If you are on 2.1.3, it's possible as the mod doesn't fully work on the latest patch.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: petewadey on March 21, 2023, 09:54:40 AM
I'm on 2.0.19
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on March 21, 2023, 05:54:45 PM
Quote from: petewadey on March 21, 2023, 09:04:58 AMNone of my older attachments are loading, and on investigation in my cpanel file manager, I notice the attachments no longer loading have been compressed, so are no longer jpg's but are ( gzip compressed data, from Unix, last modified: Thu Dec 30 01:18:29 2021, max speed )
Is this possibly anything to do with this mod?
   
@petewadey - Nothing to do with this mod - it does not do any file compression ...
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Sir Osis of Liver on April 08, 2023, 10:40:58 PM
Installed ver. 6.16 in 2.0.19, php 7.4/8.0.  Getting a lot of these -


https://www.thekrashsite.com/ferrarum/smf/index.php?action=dlattach;attach=25;type=avatar
2: Trying to access array offset on value of type null
File: /home/thekrash/public_html/ferrarum/smf/Sources/Subs-AutoRotation.php
Line: 477

https://www.thekrashsite.com/ferrarum/smf/index.php?action=dlattach;attach=25;type=avatar
Path cannot be empty


Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on April 08, 2023, 11:40:39 PM
Quote from: Sir Osis of Liver on April 08, 2023, 10:40:58 PMInstalled ver. 6.16 in 2.0.19, php 7.4/8.0.  Getting a lot of these -

https://www.thekrashsite.com/ferrarum/smf/index.php?action=dlattach;attach=25;type=avatar
2: Trying to access array offset on value of type null
File: /home/thekrash/public_html/ferrarum/smf/Sources/Subs-AutoRotation.php
Line: 477

https://www.thekrashsite.com/ferrarum/smf/index.php?action=dlattach;attach=25;type=avatar
Path cannot be empty
Are you able to give me any info on how to reproduce this error?

Version 6.16 was released almost one year ago and this is the first time this error has been reported and it has not occurred on any of the three SMF 2.0.19 forums (all with PHP 7.4) that I manage.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Sir Osis of Liver on April 08, 2023, 11:59:59 PM
Not really sure what's happening.  Trying to update my oldest forum (Oct 2010) to run in php 8.0 with responsive theme (customized Nightbreeze).  Started with the theme, then everything went sideways, lot of mod errors.  I've restored files/database back to Apr 1 and reverted to old theme and everything's working nicely in 8.0, no errors.  This mod is currently uninstalled, will install it tomorrow and see what happens.  Host is migrating my account to new cloud platform sometime tonight, don't want to be in middle of something when they pull the plug.  I suspect it's a theme issue, I've installed the mod on several forums without problems.  Will let you know once I've got it reinstalled.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on April 09, 2023, 12:07:36 AM
Quote from: Sir Osis of Liver on April 08, 2023, 11:59:59 PMNot really sure what's happening.  Trying to update my oldest forum (Oct 2010) to run in php 8.0 with responsive theme (customized Nightbreeze).  Started with the theme, then everything went sideways, lot of mod errors.  I've restored files/database back to Apr 1 and reverted to old theme and everything's working nicely in 8.0, no errors.  This mod is currently uninstalled, will install it tomorrow and see what happens.  Host is migrating my account to new cloud platform sometime tonight, don't want to be in middle of something when they pull the plug.  I suspect it's a theme issue, I've installed the mod on several forums without problems.  Will let you know once I've got it reinstalled.

OK - I've looked into this some more just now and the line of code in Subs-AutoRotation.php that's throwing the error calls the 'getAttachmentFilename' function in Subs.php and that function expects the setting 'attachmentUploadDir' to have a value.

Maybe try running 'repair_settings' and/or the checking that all the required avatar settings are configured.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on April 09, 2023, 08:25:33 AM
I've been able to reproduce this error with SMF 2.0.19 and both PHP 7.4 and 8.0 but it specifically relates to user uploaded avatars for which all of the following conditions are met:
1. The uploaded avatar has been saved into the default attachments directory (ie, not into a separate avatars directory)*;
2. The avatar have been saved in JPG format;
3. This mod is enabled; and
4. The mod option 'Resize, compress and/or reformat existing images when messages are displayed' is enabled.


* This is relevant because, and contrary to the information posted here (https://www.simplemachines.org/community/index.php?msg=4106581), uploaded avatars that are saved into the default attachments directory are given an 'attachment_type' value of 0 in the database whereas uploaded avatars that are saved into a separate avatars directory are given an 'attachment_type' value of 1.
avatar_save_location.jpg

By default this mod will not try to resize JPG avatars but the test used for determining if a JPG image is an avatar was based on the assumption that all user uploaded avatars had an 'attachment_type' value of 1.

For the next release I've updated the mod to use a more robust test for determining if a JPG image is an avatar.

In the meantime the workaround is to disable the mod option 'Resize, compress and/or reformat existing images when messages are displayed'.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Sir Osis of Liver on April 09, 2023, 07:56:25 PM
Ok, cleaned up install and theme, all mods installed ok, one manual edit for this mod in Subs-Graphics.php.  Member's avatar does not display, getting these errors:


https://www.thekrashsite.com/ferrarum/smf/index.php?action=dlattach;attach=25;type=avatar
Path cannot be empty

https://www.thekrashsite.com/ferrarum/smf/index.php?action=dlattach;attach=25;type=avatar
2: Trying to access array offset on value of type null
File: /home/thekrash/public_html/ferrarum/smf/Sources/Subs-AutoRotation.php
Line: 477


Unistalled mod, avatar reappears.  Avatar is an uploaded jpg in /attachments.

Manual edit was for this -


    );

    require_once($sourcedir . '/Subs-Package.php');
    @ini_set('memory_limit', '512M');


I had increased memory limit at some point.  There's a stray character in replacement code -


,
        // 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.


Comma upper left, makes no difference either way.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on April 09, 2023, 09:10:24 PM
Quote from: Sir Osis of Liver on April 09, 2023, 07:56:25 PMOk, cleaned up install and theme, all mods installed ok, one manual edit for this mod in Subs-Graphics.php.  Member's avatar does not display, getting these errors:

https://www.thekrashsite.com/ferrarum/smf/index.php?action=dlattach;attach=25;type=avatar
Path cannot be empty

https://www.thekrashsite.com/ferrarum/smf/index.php?action=dlattach;attach=25;type=avatar
2: Trying to access array offset on value of type null
File: /home/thekrash/public_html/ferrarum/smf/Sources/Subs-AutoRotation.php
Line: 477

Unistalled mod, avatar reappears.  Avatar is an uploaded jpg in /attachments.
Okay - as per my reply above (https://www.simplemachines.org/community/index.php?msg=4150155) the workaround is to disable the mod option 'Resize, compress and/or reformat existing images when messages are displayed'.

However, if you don't want to do that another option is to add the following code to ./Sources/Subs-AutoRotation.php
Find:
    if (!is_array($attachment) && ($attachmentType == 0 || $attachmentType == 3))

Add Before:
    // Nothing to do for JPG avatars that have snuck through ...
    if (isset($_REQUEST['type']) && $_REQUEST['type'] == 'avatar')
        return;

Note: This is the new avatar test I've added for the next version of this mod and, due to this file being removed/replaced when the mod is subsequently uninstalled/upgraded, making this code change will not cause any problems for either the uninstall/upgrade processes.



QuoteManual edit was for this -

    );

    require_once($sourcedir . '/Subs-Package.php');
    @ini_set('memory_limit', '512M');


I had increased memory limit at some point.  There's a stray character in replacement code -

,
        // 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.

Comma upper left, makes no difference either way.

It's not a stray character - the comma is needed to add another element to the 'default_formats' array in the 'resizeImageFile' function and the net effect of this code update in a default SMF 2.0.19 ./Sources/Subs-Graphics.php file is to change this block of code ...
    static $default_formats = array(
        '1' => 'gif',
        '2' => 'jpeg',
        '3' => 'png',
        '6' => 'bmp',
        '15' => 'wbmp'
    );

    require_once($sourcedir . '/Subs-Package.php');
    @ini_set('memory_limit', '90M');

    $success = false;

... to this block of code:
    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;

Finally, the attachment memory processing limit can be configured via a mod setting.
Memory.jpg
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Sir Osis of Liver on April 10, 2023, 12:43:21 PM
Will do the code change tonight.  Hard part will be remembering which forums I've installed this on, but haven't had any complaints.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Ricsca on April 14, 2023, 04:53:44 PM
This mod should default to smf, it saves a lot of memory by resizing images.
Thanks
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Arantor on April 14, 2023, 04:56:57 PM
Quote from: Ricsca on April 14, 2023, 04:53:44 PMThis mod should default to smf

It should be an option, yes, but not necessarily the default; there are people who will not want the rotation or resizing automatically. Photography forums, for example.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on April 14, 2023, 06:13:59 PM
Quote from: Arantor on April 14, 2023, 04:56:57 PMIt should be an option, yes, but not necessarily the default; there are people who will not want the rotation or resizing automatically. Photography forums, for example.
Automatic image rotation is the default behaviour in SMF 2.1.x and without this mod there is no option to disable it ...
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Arantor on April 14, 2023, 06:43:21 PM
It is? I don't remember it being added, and honestly... it's not a solid default to have that can't be changed.

Permanently altering an image as an upload is not the sort of thing that should be done lightly.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on April 14, 2023, 07:36:56 PM
Quote from: Arantor on April 14, 2023, 06:43:21 PMIt is? I don't remember it being added, and honestly... it's not a solid default to have that can't be changed.
Definitely happens for JPEG images with orientation EXIF metadata ...


Interestingly, ./Sources/Subs-Graphics.php also contains code in the 'resizeImage' function that is probably intended to automatically save JPEG images at 82% compression (a hard coded value rather than a configurable setting) if iMagick is available but that isn't happening because the wrong iMagick method is used.
            if ($default_formats[$preferred_format] == 'jpeg')
                $imagick->setCompressionQuality(!empty($modSettings['avatar_jpeg_quality']) ? $modSettings['avatar_jpeg_quality'] : 82);

The method (https://www.php.net/manual/en/imagick.setcompressionquality.php) should be 'setImageQuality' instead of 'setCompressionQuality'.  Also, I can't find any setting for avatar JPEG quality ...
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Kindred on April 14, 2023, 07:50:25 PM
That's browser behavior based on the exif,  not the system
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on April 14, 2023, 07:56:34 PM
Quote from: Kindred on April 14, 2023, 07:50:25 PMThat's browser behavior based on the exif,  not the system
I've tested this and can confirm that even though a browser will automatically display a rotated JPEG image when it is uploaded it is the code in the 'resizeImage' function in ./Sources/Subs-Graphics.php that saves it as a rotated JPEG image to the file system.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Arantor on April 15, 2023, 01:15:50 AM
I remember fighting so hard with EXIF orientation in LevGal because browsers *didn't* display that correctly, haha.

But yeah, auto-damaging images (folks without ImageMagick will get the EXIF data all stripped) isn't cool. Especially as a non trivial selection of hosts don't use either Imagick or MagickWand but punt it out to the shell version.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: @rjen on April 15, 2023, 02:12:30 AM
I like this mod, mod not the amount of code changes it makes.

I would like the auto resize option as a stand-alone hooks only mod.
Also would not mind helping putting that mod together ...
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on April 15, 2023, 08:13:19 PM
Quote from: @rjen on April 15, 2023, 02:12:30 AMI like this mod, mod not the amount of code changes it makes.
Most of the source code changes are for handling automatic and/or manual image rotation.

QuoteI would like the auto resize option as a stand-alone hooks only mod.
I worked with @dougiefresh just over five years ago (https://www.simplemachines.org/community/index.php?msg=3967342) to add automatic image resizing to this mod because at the time it made sense to both of us for images that needed to be rotated to also be resized but also for both of these features to work independently of each other.

This mod has four separate features for image resizing:
1. Automatically resize new images using mod settings when they are saved to a new or existing message;
2. Automatically resize existing images using mod settings when a message is displayed (this function is of use when the mod is installed on a forum where uploaded images have not previously been resized and/or when the mod settings are changed.);
3. Function to batch resize all existing images using mod settings (this function is also of use when the mod is installed on a forum where uploaded images have not previously been resized and/or when the mod settings are changed but once this is done the setting for automatically resizing existing images using mod settings when a message is displayed can be disabled); and
4. Option to have different two different sets of mod settings for resizing (this enables some member groups to choose which set of resizing options to use when they upload an image - I find this particularly useful for managing the resizing of technical images that have been saved in JPEG format).  That said, I have not been able to work out how to make this a selectable option in SMF 2.1.x ...

I'll start looking into what I need to do to develop a separate 'Resize' mod that is hooks only (but only SMF 2.1.x).

QuoteAlso would not mind helping putting that mod together ...
Thanks.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Volker S on April 16, 2023, 09:46:25 AM
I'm an absolute layman and can therefore not judge whether my proposal is feasible or not.
A great option, which is admittedly not often needed, would be a presentation in an external graphics program to be able to show details better.
This means that the graphic does not need to be scaled down to forum size, but just enough to fill a standard screen (adjustable).
Otherwise, your addon is absolutely top class and I thank you very much for the time you spent on it.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Ricsca on April 22, 2023, 03:54:53 PM
the ability to resize images is more fundamental than rotation.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Arantor on April 22, 2023, 04:05:32 PM
Says you. I know at least one community that would rather not have rotation *OR* resizing in favour of full size full quality. That alone means it must be an option rather than the ONLY option as you're outlining.

In any case, storage isn't that expensive - Hetzner has 100GB storage for around $10/month, 300GB for $20/month which includes web hosting. But if you're in a place where your budget is that constrained, I'd be wondering if running a forum at all is viable - especially since I've seen you complain so furiously at how expensive IPS is over at TAZ...
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: bmwplow on April 22, 2023, 04:52:55 PM
Hello,

Testing this on my test forum. SMF 2.0.19 with Nightbreeze before I roll it out on my production forum. 5.9 has been working great, but when changing to 6.16 I am getting some errors and can't even load the attachment settings section:

When loading the attachment settings section:

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

At top of forum, also have:
// Automatic Attachment Rotation (and Resize) mod. $txt['attachment_autorotation_settings'] = 'Automatic Attachment Rotation (and Resize) mod.'; $txt['attachment_manager_resize'] = 'Resize/Reformat Existing Images'; $txt['attachment_manager_resize_no_entries'] = 'There are no images for
Resize/Reformat Existing Images
to process.';

Running php 7.4 currently but hoping to fix this and convert to at least 8.0 soon to keep host happy.

Any suggestions would be appreciated. I love the mod.

Thank you so much.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on April 22, 2023, 06:19:03 PM
The problem you've reported is most likely due to a corruption of the ./Themes/default/languages/Admin.english.php file.

When this mod is installed it adds these strings just before the end of the file but sometimes other mods do not install their strings correctly which results in the last line of file not being in the correct/expected format.

The last line of the file should look like this (ie, the '?>' characters should be on a separate line):
?>

However, if another mod has added its strings incorrectly the '?>' characters may now be at the end of a text string line with the result that the strings added by this mod now appear below these characters.

The fix is to edit the language file, delete the '?>' characters from the end of the text string line where they currently appear, and add the following line to the end of the file:
?>

Title: Re: Automatic Attachment Rotation (and Resize)
Post by: bmwplow on April 22, 2023, 07:33:31 PM
Great, thank you so much. Will take a look.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: bmwplow on April 22, 2023, 10:31:04 PM
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.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on April 22, 2023, 11:05:34 PM
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?
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: bmwplow on April 24, 2023, 11:14:22 PM
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.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Sir Osis of Liver on May 05, 2023, 09:59:48 PM
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

Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on May 05, 2023, 10:22:54 PM
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).
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Sir Osis of Liver on May 05, 2023, 10:29:11 PM
I've used the mod on several forums, but it's not working on this one.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on May 05, 2023, 10:45:42 PM
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?
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Sir Osis of Liver on May 05, 2023, 11:07:26 PM
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.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on May 05, 2023, 11:13:09 PM
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)
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Sir Osis of Liver on May 05, 2023, 11:25:35 PM
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
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Sir Osis of Liver on May 05, 2023, 11:28:55 PM
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
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Sir Osis of Liver on May 05, 2023, 11:55:55 PM
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.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on May 06, 2023, 12:05:04 AM
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.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Sir Osis of Liver on May 06, 2023, 12:11:57 AM
Imagick and GD are both enabled in php 8, but mod is not seeing Imagick.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Sir Osis of Liver on May 06, 2023, 12:16:12 AM
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?
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on May 06, 2023, 12:35:27 AM
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 ...
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Sir Osis of Liver on May 06, 2023, 10:58:58 PM
Host support suggested that mod may not be compatible with newer version of GD.  Are you using 2.3.3?
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on May 07, 2023, 08:53:26 AM
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.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on May 07, 2023, 07:45:48 PM
I've just confirmed that this issue occurs with PHP 8.0 but not with PHP 7.4 - now just gotta work out why ...
PHP8.0_SMF2.0.19 Issue.jpg


Edit:
Found out why - see PHP 8.0 : \GDImage object is used instead of resource type (https://phpbackend.com/blog/post/php-8-0-gdimage-object-is-used-instead-of-resource-type) - and fortunately the fix looks easy to implement ...


Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Sir Osis of Liver on May 08, 2023, 12:57:08 PM
Same here, GD works in 7.4, not in 8.0.  Imagick works in both.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on May 08, 2023, 06:52:58 PM
Quote from: Sir Osis of Liver on May 08, 2023, 12:57:08 PMSame here, GD works in 7.4, not in 8.0.  Imagick works in both.

If you make the following code change in ./Sources/Subs-AutoRotation.php the mod will work with GD for PHP 8.0 (and it will still work for earlier releases of PHP).

Find:
    if ($success && is_resource($dst_img))Replace With:
    if ($success)
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Sir Osis of Liver on May 08, 2023, 10:18:22 PM
Works in GD and Imagick in php 8.0.  Nice.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: woolly bugger on June 19, 2023, 09:44:27 AM
I'm getting errors when trying to install on 2.1.4

Quote./Themes/default/Post.template.php TEST FAILES

Title: Re: Automatic Attachment Rotation (and Resize)
Post by: m4z on June 19, 2023, 03:28:00 PM
The mod doesn't claim compatibility with 2.1.3 (probably an oversight) or 2.1.4 (maybe there isn't a compatible version released yet).

What are the details of the failed test? Do you have other mods installed?
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: @rjen on June 19, 2023, 03:29:04 PM
The mod meds to be updated for 2.1.4. Author is working on it
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on July 01, 2023, 04:56:27 AM
Version 6.20 - July 01, 2023
o Added option to only allow specific image MIME types (including error message support for the SMF 2.0 Improved Attachment Error Handling (https://custom.simplemachines.org/mods/index.php?mod=3255) mod). This feature is only available for SMF 2.0.16 and later and for all SMF 2.1.1 and later.
  - If a newly attached image has a MIME type that is not supported by the forum image software (ie, GD or iMagick) an error message will be logged in the forum log with the details of the attachment name, the username, the image MIME type and forum image software.
o If the mod setting Automatically process existing images using the settings above when messages are displayed is enabled and an existing image has a MIME type that is not supported by the forum image software (ie, GD or iMagick) an error message can optionally be logged in the forum log with the details of the attachment name, the forum message it is attached to, the image MIME type and forum image software.
o Added support for some of the additional image MIME types supported by iMagick (eg, 'tiff').
o Fixed issue that generated an error message in the forum log if an attempt was made to upload an image with an allowed filename extension (eg, 'jpg') that was actually an unsupported image MIME type (eg, 'svg').
o Fixed issue that caused a memory allocation error message to be logged if the value of the PHP memory_limit is 1Gb or more.
o Fixed issue that prevented images quoted being displayed when the Post and PM Inline Attachments (https://custom.simplemachines.org/mods/index.php?mod=3770) mod was also installed.
o Fixed issue that occurred sometimes when the Image Attachment Thumbnail View (https://custom.simplemachines.org/index.php?mod=4277) mod is installed and the 'Allow members to see a thumbnail-sized view of image attachments in member profiles' setting is enabled.
o Fixed issue that prevented avatars from being displayed in the Admin Centre when the 'Display images (and thumbnails if they exist) in the Admin Center' setting was enabled.
o Fixed PHP 8.0 bug reported by Sir Osis of Liver (https://www.simplemachines.org/community/index.php?msg=4150133) that generated "Path cannot be empty" error messages for uploaded avatars that are saved into the default attachments directory in JPG format if the mod setting Automatically process existing images using the settings above when messages are displayed (was previously 'Resize, compress and/or reformat existing images when messages are displayed') is enabled (same issue with PHP 7.4 but different error messages - additional information here (https://www.simplemachines.org/community/index.php?msg=4150155)).
o Fixed PHP 8.0 bug reported by Sir Osis of Liver (https://www.simplemachines.org/community/index.php?msg=4151813) that resulted in images not being resized.
o Fixed issue in core code for SMF 2.0.16/2.1.0 and later that prevents thumbnails being created for BMP images - fix only applies if this mod is enabled.
o Fixed issue in core code that resulted in an empty thumbnail file being created if a thumbnail could not be created - only applies if this mod is enabled. (See SMF 2.0.17 - Thumbnail file with 0/zero size created (https://www.simplemachines.org/community/index.php?topic=574872.0)).
o Updated code to only remove EXIF data from newly attached JPEG images - previous versions also did this for existing images when a message was displayed if the mod setting Automatically process existing images using the settings above when messages are displayed (was previously 'Resize, compress and/or reformat existing images when messages are displayed') was enabled but because there was no way of knowing if the EXIF data had already been removed this resulted in unnecessary processing of each JPEG image every time it was displayed.
o Updated code for manual/batch resizing of images via the Administration Center as follows:
  - Images will now be rotated and/or reformatted if those settings are enabled in the mod settings (rotation only possible for JPEG images that contain orientation data).
  - Images uploaded by a member of a Primary Membergroup, Additional Membergroup, or Post Count Based Group that can choose different options will not be resized or have their JPEG quality changed.
  - Additional code updates for batch resizing via File Maintenance as follows:
    ! Link to 'readme' file with information about the recommended forum settings for this process (opens in new tab).
    ! Warning message if Maintenance Mode is not enabled.
    ! Note showing how many images need to be processed and possible time required in minutes (based on 30 images per minute).
    ! Option to delete the backup directory/folder and database table created for and used by the batch resizing process (the backup directory/folder is also used for manual processing if the setting to keep a backup of original image file is enabled).
    ! Confirmation now required for batch starting processing (and also required for deleting the backup directory/folder and database table).
o Confirmation now required for resetting the orientation flag (done via File Maintenance).
o For SMF 2.1: If automatic rotation is disabled a message will be displayed in the attachment upload area advising that even though JPEG images may be rotated when they are uploaded they will not be rotated when the message is saved.
o Removed integration support for Post and PM Inline Attachments (https://custom.simplemachines.org/mods/index.php?mod=3770) mod versions prior to v6.18.
o Added support for SMF 2.1.3 and 2.1.4.
o Removed support for releases of SMF 2.0 prior to SMF 2.0.14 and for SMF 2.1.0.
o SMF 2.0 and SMF 2.1: Language files are now installed in mod specific directory/folder.
o SMF 2.0.14-2.0.19 and SMF 2.1.1: Mod upgrade option available for v6.13, v6.14, v6.15 and v6.16.
o SMF SMF 2.1.2-2.1.3: Mod upgrade option available for v6.15 and v6.16.


Enjoy!!
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Volker S on July 01, 2023, 06:41:23 AM
First of all, a huge thank you for your extensive adaptation. Now to my question...
The procedure would then be as follows?
- Uninstall Automatic Attachment Rotation
- Update forum software from 2.1.3 to 2.1.4
- Install new version of Automatic Attachment Rotation
...is this the correct procedure?
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on July 01, 2023, 07:49:48 AM
Quote from: Volker S on July 01, 2023, 06:41:23 AMFirst of all, a huge thank you for your extensive adaptation. Now to my question...
The procedure would then be as follows?
- Uninstall Automatic Attachment Rotation
- Update forum software from 2.1.3 to 2.1.4
- Install new version of Automatic Attachment Rotation
...is this the correct procedure?
Yes - you must uninstall any previous version of this mod before you attempt to upgrade to 2.1.4.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Volker S on July 01, 2023, 12:50:39 PM
I can't import a jpg-Picture with your new Addon hier in the Forum (in my Forum i can). Because that, i use a Link.

(https://www.jollauser.de/diverses/no_Button.jpg)

In the German translation, the text leads to some confusion because there is no button. It would be better if it said the following:
"Drag your files here, or click on this line to add files."
Where can I change this - I didn't find it in the language files?

Title: Re: Automatic Attachment Rotation (and Resize)
Post by: m4z on July 01, 2023, 05:14:35 PM
Quote from: Volker S on July 01, 2023, 12:50:39 PMIn the German translation, the text leads to some confusion because there is no button. It would be better if it said the following:
"Drag your files here, or click on this line to add files."
Where can I change this - I didn't find it in the language files?

That has already been changed in the translation a month ago (it now reads "Klicken Sie hier oder ziehen Sie Dateien hierher[...]"), but apparently this forum still uses older language files. I have requested to have them updated.

You can update them on your own forum by re-adding the language. It will show the files that have been updated and you can overwrite them, losing local changes.

If you're maintaining your own translation, and don't want to lose your local changes, it's the string $txt['attach_drop_zone'] in Post.${your_language}.php.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on July 01, 2023, 05:57:32 PM
Quote from: Volker S on July 01, 2023, 12:50:39 PMI can't import a jpg-Picture with your new Addon hier in the Forum (in my Forum i can). Because that, i use a Link.

(https://www.jollauser.de/diverses/no_Button.jpg)

In the German translation, the text leads to some confusion because there is no button. It would be better if it said the following:
"Drag your files here, or click on this line to add files."
Where can I change this - I didn't find it in the language files?
This issue is not related to this mod but is a known issue with the German language pack - see Incorrect representation in SMF 2.1.4 (https://www.simplemachines.org/community/index.php?msg=4153754).
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on July 01, 2023, 08:07:01 PM
Version 6.21 - July 02, 2023
o Bug fix for issue that occasionally caused error messages to be generated for non-image attachments.


Note: There is an upgrade option for v6.20.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: m4z on July 02, 2023, 07:10:14 AM
Quote from: GL700Wing on July 01, 2023, 05:57:32 PMThis issue is not related to this mod but is a known issue with the German language pack - see Incorrect representation in SMF 2.1.4 (https://www.simplemachines.org/community/index.php?msg=4153754).

Ah, my bad. I thought that was fixed already, but apparently the language files here weren't updated after the fix landed in there. Should have poked the admins but didn't.

And because I thought that was fixed, I didn't see the connection.
[/OT]
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Volker S on July 02, 2023, 03:31:53 PM
@GL700Wing
I was just about to update your update and resize tool to the new version 6.21.
Resize_01.jpg

Here is the result:
"You cannot download or install new packages because the Packages directory, or one of the files in it, is not writable! "
Resize_02.jpg

Here is my Packages-Directorry (drwxr-xr-x / 755):
Packages.jpg
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Volker S on July 02, 2023, 04:52:00 PM
Last entry of mine can be deleted - the reason is not your mod - so I better ask in the general forum
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: @rjen on July 03, 2023, 03:57:48 PM
Just installed latest version (6.21) on SMF 2.1.4.

It works fine, but for some reason it is not picking up the Dutch language strings. Files are in the correct folder, but the descriptions will only show in English?
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on July 03, 2023, 05:53:20 PM
Quote from: @rjen on July 03, 2023, 03:57:48 PMJust installed latest version (6.21) on SMF 2.1.4.

It works fine, but for some reason it is not picking up the Dutch language strings. Files are in the correct folder, but the descriptions will only show in English?
Is that for all descriptions or only some - reason I'm asking is that some new/modified strings are only in English.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: @rjen on July 04, 2023, 01:43:01 AM
All descriptions are in English, it seems the alternate language files are not picked up at all
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on July 04, 2023, 04:52:51 AM
Quote from: @rjen on July 04, 2023, 01:43:01 AMAll descriptions are in English, it seems the alternate language files are not picked up at all
Ok - if you copy the Dutch language file to the '-utf8' variant (eg, copy name.dutch.php to name.dutch-utf8.php) does that fix the problem?
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: @rjen on July 04, 2023, 06:49:25 AM
I am on SMF 2.1.4... no utf8 needed
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on July 04, 2023, 08:46:51 AM
Quote from: @rjen on July 04, 2023, 06:49:25 AMI am on SMF 2.1.4... no utf8 needed
I know but I'm trying to help you work out why the Dutch language file isn't being used and I thought this is a test you could try ...
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Kindred on July 04, 2023, 09:10:16 AM
2.1.4 does not use the -utf8 signifier..  doesn't even look for it
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: @rjen on July 04, 2023, 11:59:33 AM
What Kindred said.

But just to be sure. Did what you asked, no change...
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: @rjen on July 04, 2023, 01:21:06 PM
Did some more checking... when hitting the help icons on the admin settings the dutch files are indeed used (without utf8), But the main text is not using it...

2023-07-04_191955.jpg
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on July 04, 2023, 05:49:12 PM
Quote from: Kindred on July 04, 2023, 09:10:16 AM2.1.4 does not use the -utf8 signifier..  doesn't even look for it
That's what I thought but I can't think of a reason why the Dutch language file isn't being used for the mod's text strings ...

Quote from: @rjen on July 04, 2023, 01:21:06 PMDid some more checking... when hitting the help icons on the admin settings the dutch files are indeed used (without utf8), But the main text is not using it...
That's even more confusing - not sure it has anything to do with the mod but I'll keep testing ...
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on July 04, 2023, 07:05:28 PM
@@rjen I've just confirmed on my test SMF 2.1.4 forum that the Dutch language file is being loaded/used for this mod - seems you have a local issue.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: natavidat on July 07, 2023, 06:27:13 PM
I have big trouble after installing this mod.
Difficult to repeat, because once isntalled, it can't be deinstallted.

But maybe the problem is PHP8. Will there be support for it?
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on July 07, 2023, 07:09:43 PM
Quote from: natavidat on July 07, 2023, 06:27:13 PMI have big trouble after installing this mod.
Difficult to repeat, because once isntalled, it can't be deinstallted.
@natavidat I can assure you this mod installs and uninstalls correctly if no errors are reported during either process.

However, you haven't provided sufficient information for me to be able to help you.

On which release of SMF of version of PHP did you install this mod?

If you've recently upgraded to SMF 2.1.4 did you uninstall this mod before upgrading to SMF 2.1.4 as required?

Did the mod installation reported any errors before you installed it?

What error messages are in the forum/server logs?

QuoteBut maybe the problem is PHP8. Will there be support for it?
This mod works with SMF 2.0.14-2.0.19 and SMF 2.1.1-2.1.4 using versions of PHP 7.4 -8.1.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: natavidat on July 08, 2023, 10:58:26 AM
Hello GL700Wing,

I suspected, that you can't help with more Informations :-( but the problem is, once installed the mos only can be uninstallted by a new isntallation of smf.
So well, I do this again.

I'm unsing 2.0.19. No upgrade.

There are no negativ signs before the installation.

I added some screenshots.

1 This is shown after the installation on the verry top of the site.
2 This is shown in the admin-area.
3 When the mod is activated.

I don't know, whta today is different, but yesterday this messages were still there after deinstallation. And yesterday the resizing dosn't wórked.
Today it work.

I hope I was able to mark clear, what I mean.




Title: Re: Automatic Attachment Rotation (and Resize)
Post by: natavidat on July 08, 2023, 11:03:06 AM
Wow, this is shown on the top when I try to manage my files.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: natavidat on July 08, 2023, 11:16:09 AM
And when I try to open an picture (unter manage pics) I get this message.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: shawnb61 on July 08, 2023, 12:38:25 PM
These issues may have nothing to do with this mod.  That last message suggests a problem with your attachment file paths.  I suggest reviewing those.

strftime() is deprecated under php8.1+, and it is used throughout SMF 2.0.x.  2.0.19 suppressed those deprecation warnings.  For some reason, the 2.0.19 logic to do so isn't working for you.

Another oddity - 2.0.19's copyright is 2021, not 2020 as in your screenshots.

These signs suggest a problem with your base 2.0.19 install.

It might be worth trying php 8.0 (which is officially supported by 2.0.19; 8.1 is not) & reviewing your attachment folders.


(FWIW, I have no problems with this mod under 2.0.19 using PHP 8.2.  Uninstall/reinstall works fine.  The deprecation warnings are properly suppressed.)
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: @rjen on July 08, 2023, 01:53:10 PM
Aftre I installed latest version on my SMF2.1.4 forum I am now seeing these errors being triggered from scheduled tasks...


guest
CLI cron.php
 /home/deb77453/domains/fjr-club.nl/public_html/Sources/Security.php (Regel 1356)  Backtrace informatie

Fouttype: Cron
Error
2: Cannot modify header information - headers already sent by (output started at /home/deb77453/domains/fjr-club.nl/public_html/Sources/Subs-AutoRotation.php:1)
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: @rjen on July 08, 2023, 02:14:20 PM
By the way, find attached the updated dutch language files for this mod
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: @rjen on July 08, 2023, 02:24:00 PM
Quote from: GL700Wing on July 04, 2023, 07:05:28 PM@@rjen I've just confirmed on my test SMF 2.1.4 forum that the Dutch language file is being loaded/used for this mod - seems you have a local issue.

Pretty sure I have it: two forums show the problem with the language files.
One is in a sub-domain, the other on a local XAMPP install

The third forum (my main forum) does not show the issue...

The old version of the Mod was working fine on all three forums, the new one does not.
I see you made some changes to determine the languange file directory. I suspect there is something in the logic that does not sit well in some forum configurations...
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: natavidat on July 08, 2023, 05:29:28 PM
Quote from: shawnb61 on July 08, 2023, 12:38:25 PMThese issues may have nothing to do with this mod.  That last message suggests a problem with your attachment file paths.  I suggest reviewing those.

I've checked the configuration of the path. it's ok.
these error only exists, when the mod is activ.
maybe there are an other problem, but it has only any effect, with this mod :-(

Quote from: shawnb61 on July 08, 2023, 12:38:25 PMAnother oddity - 2.0.19's copyright is 2021, not 2020 as in your screenshots.

These signs suggest a problem with your base 2.0.19 install.

I don't know much about this. I've inherited the forum. AFAIK it was a clean installation of 2.0.19 and added the tables for an existing forum.


Quote from: shawnb61 on July 08, 2023, 12:38:25 PMIt might be worth trying php 8.0 (which is officially supported by 2.0.19; 8.1 is not) & reviewing your attachment folders.


(FWIW, I have no problems with this mod under 2.0.19 using PHP 8.2.  Uninstall/reinstall works fine.  The deprecation warnings are properly suppressed.)

I've tried to set the server to PHP 7.3, 7.4, 8.0 and 8.2.
the error is allways the same
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on July 08, 2023, 05:36:27 PM
Quote from: @rjen on July 08, 2023, 02:24:00 PM
Quote from: GL700Wing on July 04, 2023, 07:05:28 PM@rjen I've just confirmed on my test SMF 2.1.4 forum that the Dutch language file is being loaded/used for this mod - seems you have a local issue.
Pretty sure I have it: two forums show the problem with the language files.
One is in a sub-domain, the other on a local XAMPP install

The third forum (my main forum) does not show the issue...

The old version of the Mod was working fine on all three forums, the new one does not.
Have you confirmed the Dutch language is selected in both the server settings and the user profile (in the Account Settings area)?  Also, have you tried clearing the web browser cache?

QuoteI see you made some changes to determine the language file directory. I suspect there is something in the logic that does not sit well in some forum configurations...
Other mods also do this so I didn't really expect there would be a problem.

That said, you can confirm if this is causing the issue by copying the mod language files to the default languages folder/directory and making the changes below to the following mod script files:

In ./Sources/Subs-AutoRotation.php
Find:
loadLanguage($langFileDir . '/AutoRotation');Add After:
loadLanguage('AutoRotation');
In ./Sources/Subs-ResizeExistingImages.php
Find:
loadLanguage($langFileDir . '/ResizeExistingImages');Add After:
loadLanguage('ResizeExistingImages');
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on July 08, 2023, 05:37:09 PM
Quote from: @rjen on July 08, 2023, 02:14:20 PMBy the way, find attached the updated dutch language files for this mod
Thanks - I've updated the mod with these files.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on July 08, 2023, 05:57:18 PM
Quote from: natavidat on July 08, 2023, 10:58:26 AM1 This is shown after the installation on the verry top of the site.
1.jpg

2 This is shown in the admin-area.
2.jpg
This issue is caused by another mod - typically the Tapatalk mod - not having added its text strings to the language file ./Themes/default/languages/Admin.english.php correctly.

If you edit the file ./Themes/default/languages/Admin.english.php after this mod is installed you'll likely see the following:
//Tapatalk
$txt['tapatalktitle'] = 'Tapatalk Settings';
$txt['tp_general_settings'] = 'General';
$txt['tp_other_settings'] = 'Others';
$txt['tp_board_settings'] = 'Boards';
$txt['tp_iar_settings'] = 'In App Registration';?>
// Automatic Attachment Rotation (and Resize) mod.
$txt['attachment_autorotation_settings'] = 'Automatic Attachment Rotation (and Resize) mod.';
$txt['attachment_manager_resize'] = 'Resize/Reformat Existing Images';
$txt['attachment_manager_resize_no_entries'] = 'There are no images for <em>Resize/Reformat Existing Images</em> to process.';

The problem is that ?> characters (which you can see at the end of the line immediately before text strings added by this mod) should be on a separate line at the very end of the file so if you delete them from the end of the line they are currently on and add them to a new line at the end of the file (as shown in the following code) the problem will be solved.
//Tapatalk
$txt['tapatalktitle'] = 'Tapatalk Settings';
$txt['tp_general_settings'] = 'General';
$txt['tp_other_settings'] = 'Others';
$txt['tp_board_settings'] = 'Boards';
$txt['tp_iar_settings'] = 'In App Registration';

// Automatic Attachment Rotation (and Resize) mod.
$txt['attachment_autorotation_settings'] = 'Automatic Attachment Rotation (and Resize) mod.';
$txt['attachment_manager_resize'] = 'Resize/Reformat Existing Images';
$txt['attachment_manager_resize_no_entries'] = 'There are no images for <em>Resize/Reformat Existing Images</em> to process.';

?>


However, this also tells me you are not using the latest version of the mod because it does not make updates to this file - please download v6.21 and use that.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on July 08, 2023, 06:09:22 PM
Quote from: shawnb61 on July 08, 2023, 12:38:25 PM(FWIW, I have no problems with this mod under 2.0.19 using PHP 8.2.  Uninstall/reinstall works fine.  The deprecation warnings are properly suppressed.)
BTW - I have checked all this mod's install/mod scripts going back for five years and I cannot find use of the strftime() function anywhere.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: shawnb61 on July 08, 2023, 06:31:02 PM
Correct - the strftime calls are in SMF, not in AARR.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on July 08, 2023, 06:31:30 PM
Quote from: @rjen on July 08, 2023, 01:53:10 PMAftre I installed latest version on my SMF2.1.4 forum I am now seeing these errors being triggered from scheduled tasks...


guest
CLI cron.php
 /home/deb77453/domains/fjr-club.nl/public_html/Sources/Security.php (Regel 1356)  Backtrace informatie

Fouttype: Cron
Error
2: Cannot modify header information - headers already sent by (output started at /home/deb77453/domains/fjr-club.nl/public_html/Sources/Subs-AutoRotation.php:1)
Apparently this issue can be caused by the presence of a space character before the opening PHP tag (ie, <?php) or after the closing PHP tag (ie, ?>) in a script file.

Please check the first line of the Subs-AutoRotation.php file to make sure there is no leading space.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: @rjen on July 09, 2023, 02:46:32 AM
Quote from: GL700Wing on July 08, 2023, 06:31:30 PM
Quote from: @rjen on July 08, 2023, 01:53:10 PMAftre I installed latest version on my SMF2.1.4 forum I am now seeing these errors being triggered from scheduled tasks...


guest
CLI cron.php
 /home/deb77453/domains/fjr-club.nl/public_html/Sources/Security.php (Regel 1356)  Backtrace informatie

Fouttype: Cron
Error
2: Cannot modify header information - headers already sent by (output started at /home/deb77453/domains/fjr-club.nl/public_html/Sources/Subs-AutoRotation.php:1)
Apparently this issue can be caused by the presence of a space character before the opening PHP tag (ie, <?php) or after the closing PHP tag (ie, ?>) in a script file.

Please check the first line of the Subs-AutoRotation.php file to make sure there is no leading space.

There was no leading space there, but it seems to have an extra line feed at the end.
Removed that, let's see if it make a difference
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on July 09, 2023, 02:52:31 AM
Quote from: @rjen on July 09, 2023, 02:46:32 AMNo leading space there
OK - just wondering if there is a non-printable character at the beginning of the first line - maybe try completely deleting the first line, save the file and then reinsert the first line with the opening PHP tag (ie, <?php).

BTW - this is not happening on my test SMF 2.1 forums.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: @rjen on July 09, 2023, 02:56:52 AM
Quote from: GL700Wing on July 08, 2023, 05:36:27 PMHave you confirmed the Dutch language is selected in both the server settings and the user profile (in the Account Settings area)?  Also, have you tried clearing the web browser cache?

That was it: the issue occurs when the forum default language is English, but the user language is Dutch.
When I set them both to dutch the dutch strings are showing, but when I set the forum language to english and the user language to dutch, the strange hybrid situation occurs...

Just checked the other way around is the same: the language showing in the admin scren is following the main forum language, ignoring the user language..
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on July 09, 2023, 03:07:52 AM
Quote from: @rjen on July 09, 2023, 02:46:32 AMThere was no leading space there, but it seems to have an extra line feed at the end.
Removed that, let's see if it make a difference
Interesting because there is no extra line after the closing PHP tag in that file in the mod package.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on July 09, 2023, 03:09:23 AM
Quote from: @rjen on July 09, 2023, 02:56:52 AM
Quote from: GL700Wing on July 08, 2023, 05:36:27 PMHave you confirmed the Dutch language is selected in both the server settings and the user profile (in the Account Settings area)?  Also, have you tried clearing the web browser cache?

That was it: the issue occurs when the forum default language is English, but the user language is Dutch.
When I set them both to dutch the dutch strings are showing, but when I set the forum language to english and the user language to dutch, the strange hybrid situation occurs...

Just checked the other way around is the same: the language showing in the admin scren is following the main forum language, ignoring the user language..
Glad you've got it solved although it seems to highlight an issue with how SMF is implementing languages ...
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: @rjen on July 09, 2023, 03:18:35 AM
Perhaps, but at this time your mod package seems to be first one bringing the issue to light ...

The admin settings of other mods are showing the correct language strings

Perhaps a developer can shed some lights on this?
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: @rjen on July 09, 2023, 05:44:28 AM
Quote from: GL700Wing on July 09, 2023, 03:07:52 AM
Quote from: @rjen on July 09, 2023, 02:46:32 AMThere was no leading space there, but it seems to have an extra line feed at the end.
Removed that, let's see if it make a difference
Interesting because there is no extra line after the closing PHP tag in that file in the mod package.

Found the issue (I think)
See: https://www.simplemachines.org/community/index.php?topic=573373.msg4057055#msg4057055

The file Subs-AutoRotation.php in your package is encoded as UTF-8-BOM, and not as UTF-8.
In Hex editor the extra characters are showing...

Changed the encoding to UTF-8 and now they are gone

Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on July 09, 2023, 08:38:51 AM
Quote from: @rjen on July 09, 2023, 05:44:28 AMFound the issue (I think)
See: https://www.simplemachines.org/community/index.php?topic=573373.msg4057055#msg4057055

The file Subs-AutoRotation.php in your package is encoded as UTF-8-BOM, and not as UTF-8.
In Hex editor the extra characters are showing...

Changed the encoding to UTF-8 and now they are gone.
Hah - great find - well done!!

As per my previous message I was wondering if there was some non-printable character issue but I honestly don't know how that file ended encoded as UTF-8-BOM - it should just be ANSI/ASCII - because the previous versions were ANSI/ASCII and the other mod script file is ANSI/ASCII.

File re-encoded and mod package file updated!
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: natavidat on July 09, 2023, 12:14:43 PM
Quote from: GL700Wing on July 08, 2023, 05:57:18 PMHowever, this also tells me you are not using the latest version of the mod because it does not make updates to this file - please download v6.21 and use that.

I don't know why I've used the older version.

Thank you for this advice. With the newer Version it works :-)
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: maximus23 on July 11, 2023, 04:35:42 AM
Hi,

French Translation for Smf 2.0 and 2.1.

:)
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on July 11, 2023, 06:28:57 AM
Quote from: maximus23 on July 11, 2023, 04:35:42 AMHi,

French Translation for Smf 2.0 and 2.1.

:)

Many thanks - I noticed the zip files include translations for the 'Batch Resizing' readme file so I've accepted the challenge to update the mod to work with different translations for this file!  ;)
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: elexx on July 13, 2023, 12:01:10 PM
Quote from: @rjen on July 09, 2023, 05:44:28 AMThe file Subs-AutoRotation.php in your package is encoded as UTF-8-BOM, and not as UTF-8.
In Hex editor the extra characters are showing...

Changed the encoding to UTF-8 and now they are gone

I had the same problem with SMF 2.1.4 and AARR 6.21.
Downloaded the Subs-AutoRotation.php , changed encoding from UTF-8-BOM to UTF-8, saved and uploaded again. problem gone!

Thank you for this simple solution!
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on July 13, 2023, 05:03:43 PM
Quote from: elexx on July 13, 2023, 12:01:10 PM
Quote from: @rjen on July 09, 2023, 05:44:28 AMThe file Subs-AutoRotation.php in your package is encoded as UTF-8-BOM, and not as UTF-8.
In Hex editor the extra characters are showing...

Changed the encoding to UTF-8 and now they are gone

I had the same problem with SMF 2.1.4 and AARR 6.21.
Downloaded the Subs-AutoRotation.php , changed encoding from UTF-8-BOM to UTF-8, saved and uploaded again. problem gone!

Thank you for this simple solution!

The Subs-AutoRotation.php file should be encoded/saved as ANSI/ASCII and I updated the v6.21 package a few days ago with the correctly encoded file.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on July 22, 2023, 09:11:37 AM
Version 6.22 - July 22, 2023
o SMF 2.0: Fixed bug introduced in v6.20 that stopped manual rotation while modifying a message from working.
o Added French language files courtesy of maximus23 (https://www.simplemachines.org/community/index.php?action=profile;u=29317).
o Added language support for Batch Resizing readme file (thanks to maximus23 (https://www.simplemachines.org/community/index.php?action=profile;u=29317) for the inspiration to do this).


Notes:
1. There is an upgrade option for v6.20 and V6.21.
2. Only change for SMF 2.1 is the addition of the French language files and support for the French Batch Resizing readme file.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on August 30, 2023, 09:46:37 PM
Version 6.23 - August 31, 2023
o Bug fix for iMagick that resulted in JPEG image compression not working as expected.
o Bug fix for issue that occasionally caused error messages to be generated for non-image attachments.
o Updated code to display landscape images at correct ratio when modifying an existing message.


Note: There is an upgrade option for v6.20 - v6.22.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Westwegoman on August 30, 2023, 10:30:50 PM
Using SMF 2.1.4 and get a message when I try to attach a photo. Nothing in error log.
Server responded with 500 code.
When I uninstall the mod, I am able to attach.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on August 30, 2023, 11:09:46 PM
Quote from: Westwegoman on August 30, 2023, 10:30:50 PMUsing SMF 2.1.4 and get a message when I try to attach a photo. Nothing in error log.
Server responded with 500 code.
When I uninstall the mod, I am able to attach.
I cannot reproduce this issue - which version of SMF and the mod are you using?

Also, please post a screen capture of the mod settings you are using.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Westwegoman on September 01, 2023, 10:28:13 AM
I'm trying it from my iPhone today and now it's saying the file is too big, even though I am pretty sure I have the setting set large enough.

SMF version 2.1.4
Mod version 6.23
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Westwegoman on September 01, 2023, 10:32:20 AM
So I just realized that I had it set to 2,000kb and my file was 2.1mb. I changed it to 3,000 on and then I got the error shown in the attached photo.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Aleksi "Lex" Kilpinen on September 01, 2023, 11:24:38 AM
500 is a server side error, check your server error log.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Westwegoman on September 01, 2023, 11:26:12 AM
Quote from: Aleksi "Lex" Kilpinen on September 01, 2023, 11:24:38 AM500 is a server side error, check your server error log.

Ok. I'll have to look into that. I just found it odd that it did it only when the mod is installed. Mod is also installed on a few other 2.0.xx forums that I have and works flawlessly.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on September 02, 2023, 02:12:43 AM
Version 6.24 - September 02, 2023
o Bug fix for some images being incorrectly resized when a message was displayed. The issue only occurred for images uploaded by a member who could choose non-default settings if all of the following conditions were met:
  - the member chose non-default settings when attaching the image(s);
  - the 'Enable different image compression and/or resizing values for some membergroups' setting was enabled; and
  - the 'Automatically process existing images using the settings above when messages are displayed' setting was enabled.


Note: There is an upgrade option for v6.20 - v6.23.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: gevv on December 31, 2023, 09:23:24 AM
Hi, when uploading a gif image, its format changes to jpg. Is there a solution? (gif image size is small)

Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Aleksi "Lex" Kilpinen on December 31, 2023, 09:46:31 AM
I'd assume disabling the setting "Reformat non-JPEG images to JPEG" would be worth a try.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: gevv on December 31, 2023, 01:14:44 PM
Thanks. I did what you said and it was uploaded as a gif but the animation disappeared.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Arantor on December 31, 2023, 01:20:37 PM
Then it was resized, there's no way natively in PHP to resize a GIF and not lose the animation (this requires ImageMagick which few mods support)
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: gevv on December 31, 2023, 02:10:08 PM
no resizing  gif size does not exceed the limit (1600px)
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Arantor on December 31, 2023, 03:49:20 PM
Well, it looks like it's processing it anyway even though it apparently shouldn't?
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on December 31, 2023, 04:19:29 PM
I believe this is a native SMF issue (ie, not related to this mod and you can confirm this by disabling the mod) - see the following posts:
Gifs freeze after upload (https://www.simplemachines.org/community/index.php?topic=515589.msg3645962#msg3645962)
Animation stops (https://www.simplemachines.org/community/index.php?topic=534909.msg3800741#msg3800741)

An old forum post on GIFs as possible security risks:
How can an image be a security risk? (https://www.simplemachines.org/community/index.php?topic=483096.msg3383146#msg3383146)

And some recent reports in the media of GIFs containing malicious code/malware:
Hackers can now sneak malware into the GIFs you share (https://www.digitaltrends.com/computing/hackers-sneak-malware-into-gifs/)
Researchers Find Malware Hiding in GIFs (https://www.eteknix.com/researchers-find-malware-hiding-in-gifs/)
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Kindred on December 31, 2023, 05:20:21 PM
Smf does not natively force a process of gifs which are under the defined size limit.
Animated gifs work just fine in smf core
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on December 31, 2023, 05:52:23 PM
Quote from: Kindred on December 31, 2023, 05:20:21 PMSmf does not natively force a process of gift which are under the defined size limit.
Animated gift work just fine in smf core
I've confirmed two things:
1. SMF 2.1 does not resize GIFs even if they are larger than the configured maximum width/height values; and
2. There is a bug when this mod is enabled that is causing it to compress images when it shouldn't (I'll work on a fix for this as soon as I can).
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on December 31, 2023, 07:52:25 PM
@gevv I found a bug in the main script file that was causing it to compress images even if they aren't a JPEG image or being reformatted to JPEG.

I've attached an updated script file in which I've changed the code so that now only JPEG images (or images that are being reformatted to JPEG) will be compressed and I'll include these changes in the next release of the mod.


Note: Replacing the existing ./Sources/Subs-AutoRotation.php file with the attached file will not cause package manager issues if you subsequently decide to uninstall or later upgrade the mod.  However, if you uninstall/reinstall v6.24 of the mod you will need to replace the default Subs-AutoRotation.php with the attached file.

Title: Re: Automatic Attachment Rotation (and Resize)
Post by: gevv on January 01, 2024, 10:09:24 AM
Hi,  Thanks @GL700Wing and to everyone.

I updated the file and the problem was solved. I will heed the warning.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: sbartelski on March 12, 2024, 02:20:20 PM
I moved my (working) version of our forums to a different provider, and now get the message below when I access the File Maintenance or Resize, Rotate and/or Reformat Existing Images functions. Can you point me in the right direction to troubleshoot this? I include my Attachment Settings too.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: sbartelski on March 12, 2024, 02:35:32 PM
Quote from: sbartelski on March 12, 2024, 02:20:20 PMI moved my (working) version of our forums to a different provider, and now get the message below when I access the File Maintenance or Resize, Rotate and/or Reformat Existing Images functions. Can you point me in the right direction to troubleshoot this? I include my Attachment Settings too.

Fixed. While I was waiting, I happened to dig into the new providers Knowledge Base and found a memory limit setting. There was no entry for that setting in the php settings file, so I added it, starting with the suggest value of 300M. As that is larger than the memory in the error message, I was hoping that it would work. And it did!

Call my question closed. Next time I will dig first and then ask next .
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on March 12, 2024, 02:37:02 PM
Given this issue only started when you moved servers it seems to me that you need to increase the value for the setting The amount of server memory (in megabytes) to allocate to image rotation/resizing (eg, 128). from 24 (which is very low).

Title: Re: Automatic Attachment Rotation (and Resize)
Post by: sbartelski on March 12, 2024, 02:52:26 PM
Quote from: GL700Wing on March 12, 2024, 02:37:02 PMGiven this issue only started when you moved servers it seems to me that you need to increase the value for the setting The amount of server memory (in megabytes) to allocate to image rotation/resizing (eg, 128). from 24 (which is very low).



You are probably right as I now had this error when I started the batch resize"

Fatal error: Uncaught ImagickException: invalid colormap index `/home/dh_p6nj8d/clc-smf-test.dreamhosters.com/attachments/372_275496b80036df18775e7cc514eb1787a8b8edcd.dat' @ error/colormap-private.h/ConstrainColormapIndex/35 in /home/dh_p6nj8d/clc-smf-test.dreamhosters.com/Sources/Subs-AutoRotation.php:2062 Stack trace: #0 /home/dh_p6nj8d/clc-smf-test.dreamhosters.com/Sources/Subs-AutoRotation.php(2062): Imagick->__construct('/home/dh_p6nj8d...')
#1 /home/dh_p6nj8d/clc-smf-test.dreamhosters.com/Sources/Subs-AutoRotation.php(1103): AutoRotation_Process('/home/dh_p6nj8d...', 0, '65', 'jpeg')
#2 /home/dh_p6nj8d/clc-smf-test.dreamhosters.com/Sources/Subs-ResizeExistingImages.php(163): AutoRotation_ResizeExisting(Array)
#3 /home/dh_p6nj8d/clc-smf-test.dreamhosters.com/Sources/Subs.php(6030): ResizeBatch()
#4 /home/dh_p6nj8d/clc-smf-test.dreamhosters.com/Sources/ManageAttachments.php(92): call_helper('ResizeBatch')
#5 /home/dh_p6nj8d/clc-smf-test.dreamhosters.com/Sources/Admin.php(499): ManageAttachments()
#6 /home/dh_p6nj8d/clc-smf-test.dreamhosters.com/index.php(186): AdminMain()
#7 {main} thrown in /home/dh_p6nj8d/clc-smf-test.dreamhosters.com/Sources/Subs-AutoRotation.php on line 2062
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on March 12, 2024, 02:58:40 PM
That iMagick error (ie, invalid colormap index) could be caused by a corrupt image (possibly a GIF).

BTW: The image file name is ./attachments/372_275496b80036df18775e7cc514eb1787a8b8edcd.dat
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: sbartelski on March 12, 2024, 02:59:55 PM
And it sems to be running now, did about 700 and then:

Fatal error: Uncaught ImagickException: Bogus DQT index 10 `/home/dh_p6nj8d/clc-smf-test.dreamhosters.com/attachments/2738_3fa02b5d7980b984af97be4fb340d82e313e586c.dat' @ error/jpeg.c/JPEGErrorHandler/335 in /home/dh_p6nj8d/clc-smf-test.dreamhosters.com/Sources/Subs-AutoRotation.php:2062 Stack trace:
#0 /home/dh_p6nj8d/clc-smf-test.dreamhosters.com/Sources/Subs-AutoRotation.php(2062): Imagick->__construct('/home/dh_p6nj8d...')
#1 /home/dh_p6nj8d/clc-smf-test.dreamhosters.com/Sources/Subs-AutoRotation.php(1103): AutoRotation_Process('/home/dh_p6nj8d...', 1, '65', 'jpeg')
#2 /home/dh_p6nj8d/clc-smf-test.dreamhosters.com/Sources/Subs-ResizeExistingImages.php(163): AutoRotation_ResizeExisting(Array)
#3 /home/dh_p6nj8d/clc-smf-test.dreamhosters.com/Sources/Subs.php(6030): ResizeBatch()
#4 /home/dh_p6nj8d/clc-smf-test.dreamhosters.com/Sources/ManageAttachments.php(92): call_helper('ResizeBatch')
#5 /home/dh_p6nj8d/clc-smf-test.dreamhosters.com/Sources/Admin.php(499): ManageAttachments()
#6 /home/dh_p6nj8d/clc-smf-test.dreamhosters.com/index.php(186): AdminMain()
#7 {main} thrown in /home/dh_p6nj8d/clc-smf-test.dreamhosters.com/Sources/Subs-AutoRotation.php on line 2062

I did do the Attachment Integrity Test, clicked all boxes.
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: sbartelski on March 12, 2024, 03:01:09 PM
Quote from: GL700Wing on March 12, 2024, 02:58:40 PMThat iMagick error (ie, invalid colormap index) could be caused by a corrupt image (possibly a GIF).

BTW: The image file name is ./attachments/372_275496b80036df18775e7cc514eb1787a8b8edcd.dat
Can I exclude .dat files from processing?
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on March 12, 2024, 03:12:52 PM
Quote from: sbartelski on March 12, 2024, 03:01:09 PM
Quote from: GL700Wing on March 12, 2024, 02:58:40 PMThat iMagick error (ie, invalid colormap index) could be caused by a corrupt image (possibly a GIF).

BTW: The image file name is ./attachments/372_275496b80036df18775e7cc514eb1787a8b8edcd.dat
Can I exclude .dat files from processing?

You can't - that's the extension given to all attachments.

However, and instead of using the batch resizing option you could use Administration Center => Attachments and Avatars => Browse FilesBrowse Files => Resize, Rotate and/or Reformat Existing Images to process groups of selected files.
IMG_2087.jpeg

IMG_2088.jpeg
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: sbartelski on March 12, 2024, 03:13:30 PM
I will try to delete the offending file and then rerun the integrity check. Hope that I can find the file, at 80K files, even the file manager has a problem. Going to try FileZilla.

Thanks for your help.
Stefan
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: sbartelski on March 12, 2024, 03:15:13 PM
I did try that alreday, but one by one. How do I do a group?

Quote from: GL700Wing on March 12, 2024, 03:12:52 PM
Quote from: sbartelski on March 12, 2024, 03:01:09 PM
Quote from: GL700Wing on March 12, 2024, 02:58:40 PMThat iMagick error (ie, invalid colormap index) could be caused by a corrupt image (possibly a GIF).

BTW: The image file name is ./attachments/372_275496b80036df18775e7cc514eb1787a8b8edcd.dat
Can I exclude .dat files from processing?

You can't - that's the extension given to all attachments.

However, and instead of using the batch resizing option you could use Administration Center => Attachments and Avatars => Browse FilesBrowse Files => Resize, Rotate and/or Reformat Existing Images to process groups of selected files.
IMG_2087.jpeg

IMG_2088.jpeg

Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on March 12, 2024, 03:29:20 PM
Quote from: sbartelski on March 12, 2024, 03:15:13 PMI did try that alreday, but one by one. How do I do a group?
There should be checkboxes next to the image file names to enable you to select multiple images for processing.
IMG_2089.jpeg
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Klauser on March 31, 2024, 07:30:53 AM
Got an error while installing on a upgraded 2.0.19 > 2.1.4 Version

Package installation error
At least one error was found when testing the installation of the package.
It is strongly recommended that you do not proceed with the installation if you are not sufficiently knowledgeable or have not made a recent backup.

This error message may indicate a conflict between the package being installed and an existing package, an error in the package itself, or an incompatibility between the package and the SMF version.

./Sources/Subs-Graphics.php    Test failed

;

// Nothing to do without GD or IM/MW
Code (before insert) Select
, $modSettings


Title: Re: Automatic Attachment Rotation (and Resize)
Post by: Kindred on March 31, 2024, 08:03:12 AM
https://wiki.simplemachines.org/smf/Error_in_mod_installation
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: sts_pro on April 01, 2024, 06:40:27 AM
I just updated to SMF 2.1 and now manual rotation, under the post while editing, is disappeared. Anyone else is having this problem?

Found it! :) For anyone else wondering: it is now under More > Image rotation menu - not inside More > Modify interface
Title: Re: Automatic Attachment Rotation (and Resize)
Post by: GL700Wing on April 01, 2024, 02:50:30 PM
Quote from: sts_pro on April 01, 2024, 06:40:27 AMI just updated to SMF 2.1 and now manual rotation, under the post while editing, is disappeared. Anyone else is having this problem?

Found it! :) For anyone else wondering: it is now under More > Image rotation menu - not inside More > Modify interface
There are screenshots with info about the SMF 2.0 and SMF 2.1 options included with the mod description (https://custom.simplemachines.org/index.php?mod=4087) and a zip file containing all the mod screenshots can be downloaded via the 'Packages' tab.
IMG_2115.jpeg