annoying

Author Topic: Automatic Attachment Rotation v4.5  (Read 3354 times)

dougiefresh

  • Adminstrator
  • Expert Member
  • *****
  • Posts: 261
Automatic Attachment Rotation v4.5
« on: Feb 24, 2016, 08:47:40 AM »

AUTOMATIC ATTACHMENT ROTATION v4.5
By Dougiefresh -> Link to Mod


Introduction
This mod allows the automatic rotation and/or flipping of images ONLY IF the EXIF information contained within (if such exists) indicates that such processing is required in order to show the picture upright.

Features for automatic image resizing for both posts and PMs:
o Option to disable automatic image rotation
o Option to disable automatic resizing of existing images
o Option to reformat non-JPEG images to JPEG
o Option to set max width and height values for attached images
o Option to set the JPEG quality factor

NOTE: 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 that 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!

Admin Changes
In Admin => Forum => Attachments and Avatars:
o Browse Files: There is a new column for image rotation.  Note that this column isn't shown when there are no images in the list.
o File Maintenance: There is a new section with a button to clear the orientation flags in the database.

Post Screen Changes
Beside each attachment, there is a dropbox for image rotation, listing the options in the following section.

Manual Rotation Options
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

Compatibility Notes
This mod was tested on SMF 2.0.12 and 2.1 Beta 3, but should work on SMF 2.0 and up.  SMF 1.x is not and will not be supported.

The Improved Attachment Error Handling modshould be installed BEFORE this mod (if so desired) to avoid install errors.

The Resize Attachment Images mod SHOULD NOT be installed when installing this version, as this mod contains similar functionality.

Translators
o Dutch: @rjen
o Spanish Latin: Rock Lee.

Special Credit
This mod relies on the phpExifRW class, which is licensed under the GNU Lesser General Public License, 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 and at the Image Orientation thread over at the ElkArte forum.

Changelog
The changelog has been removed and can be seen at XPtsp.com.

License
Quote
Copyright (c) 2016 - 2018, Douglas Orend
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.

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.
« Last Edit: Mar 04, 2016, 07:18:22 PM by dougiefresh »

dougiefresh

  • Adminstrator
  • Expert Member
  • *****
  • Posts: 261
Re: [A] Automatic Attachment Rotation v1.0
« Reply #1 on: Feb 24, 2016, 08:48:19 AM »

Below are some preview images of what the mod looks like when being used

Download Mod


FileName: Automatic_Attachment_Rotation_v4.5.zip
Size: 44 kb (45,192 bytes)
MD5: 85f8526c983c5b75b8277e3bc2a7f4d9
Built: Apr 08, 2018, 10:35:44 AM
Downloaded 51 times

Changelog

Revised Uploaded v4.4 - April 8th, 2018
o NOTE: Statement in last version changelog "added option to disable automatic image rotation" was incomplete.
o Per GL700Wing, added option to disable automatic image rotation FOR EXISTING IMAGES.
o Per GL700Wing, fixed default JPEG quality value to be 100 instead of 0.
o Per GL700Wing, added mime type test prior to check for orientation.

Uploaded v4.4 - April 7th, 2018
o SMF 2.0: Fixed XML installer error concerning JPEG quality size.
o Per GL700Wing, added JPEQ quality check to prevent unnecessary image resizing.
o Per GL700Wing, fixed code to prevent converting to JPEG when admin option unchecked.
o Per GL700Wing, added option to disable automatic image rotation.
o Per GL700Wing, added option to disable automatic image resizing.
o Fixed a few possible undefined index array errors.

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, changed required for Image Processing Memory Limit mod was made.
o Per GL700Wing, fixed issue where JPEG quality/dimensions settings are empty.

Uploaded v4.2 - April 3rd, 2018
o Per GL700's post, fixed syntax error in Subs-AutoRotation.php.
o Per GL700's post, fixed issue where same message for rotating images as deleting images.
o Per GL700Wing, changed code to avoid "white screen of death" when rotating images manually.

Uploaded v4.1 - March 30th, 2018
o Changed some code to avoid undefined array element errors.
o Per GL700Wing, added check to see if file size is greater than 0.

Uploaded v4.0 - March 27th, 2018
o Per GL700Wing, fixed issue where images with very large dimensions could not be rotated (Image Processing Memory Limit mod may also be required if issue persists).
o Per GL700Wing, code added to automatically resize images in new and existing topics.
o Per GL700Wing, added automatic rotation and automatic resize for images in PMs if 'PM Attachments' mod is installed.

Uploaded v3.12 - February 22nd, 2018
o Added Dutch translation, courtsey of @rjen!
o 2nd attempt: Changed order of rotation/flip strings in templates, per GL700Wing's post above.
o Changed documentation to reflect new order of manual rotation options.

Uploaded v3.11 - February 20th, 2018
o Updated Spanish Latin translations, courtsey of Rock Lee.
o Changed rotation/flip strings for better understandability, per GL700Wing's post above.
o Changed order of rotation/flip strings in templates, per GL700Wing's post above.

Uploaded v3.10 - February 17th, 2018
o Included "Non well-formed number" fix by GL700Wing, as discussed here.

Uploaded v3.9 - February 13th, 2018
o Added Spanish Latin translation, courtsey of Rock Lee.
o Added translators section to README.txt.
o Added LICENSE.txt to satisfy licensing concerns.

Uploaded v3.8 - October 9th, 2017
o Fixed syntax error in code that builds the attachment link.

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

Uploaded v3.7 - September 12th, 2017
o Resolved conflict with Post and PM Inline Attachments.  No functionality change.

Uploaded v3.6 - September 8th, 2017
o Fixed 2 syntax errors in Subs-AutoRotation.php.

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.

Uploaded v3.4 - August 5th, 2017
o Added code to dynamically adjust memory to try to stop white screen issues.

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.

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 EXIF function testing.

Uploaded v3.1 - October 31th, 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.

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.

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.

Uploaded v2.3 - September 26th, 2016
o Added code to include timestamps on attachment URLs to circumvent browser caching.

Uploaded v2.2 - September 20th, 2016
o Fixed syntax error found in Subs-AutoRotation.php.  Thanks, kungfujoe!
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.

Uploaded v2.1 - September 20th, 2016
o Fixed unknown column error in Display.php that occurs when thumbnails are disabled.

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.

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

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.

Uploaded v1.0 - February 24th, 2016
o Initial release to the public

« Last Edit: Oct 29, 2016, 07:53:33 PM by dougiefresh »

dan4ever

  • Newbie
  • Posts: 3
Re: Automatic Attachment Rotation v1.2
« Reply #2 on: Jul 06, 2016, 12:03:27 PM »
I still need to turn the tumbnails...

/Dan
« Last Edit: Jul 06, 2016, 12:04:12 PM by dan4ever »

Faison

  • Newbie
  • Posts: 1
Re: Automatic Attachment Rotation v1.2
« Reply #3 on: Oct 30, 2017, 11:01:54 AM »
I still need to turn the tumbnails...

/Dan

And how do you do that?