Advertisement:

Author Topic: Automatic Attachment Rotation  (Read 22264 times)

Offline dougiefresh

  • SMF Hero
  • ******
  • Posts: 2,499
    • XPtsp.com Community
Automatic Attachment Rotation
« on: March 04, 2016, 07:34:59 PM »
Link to Mod


AUTOMATIC ATTACHMENT ROTATION v3.8
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.

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

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.

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 - 2017, 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.
NOTICE:  My website is back up!

My Free Simple Machines mods on XPtsp.com, Simple Machines Customization Site, and at GitHub!
Problem uninstalling mods?  Try Arantor's Sortable Packages (and Installed Time) mod!  It's super helpful!

Offline dougiefresh

  • SMF Hero
  • ******
  • Posts: 2,499
    • XPtsp.com Community
Re: Automatic Attachment Rotation
« Reply #1 on: March 13, 2016, 08:30:35 PM »
Bug report and response to said bug report:
@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.....  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
NOTICE:  My website is back up!

My Free Simple Machines mods on XPtsp.com, Simple Machines Customization Site, and at GitHub!
Problem uninstalling mods?  Try Arantor's Sortable Packages (and Installed Time) mod!  It's super helpful!

Offline FrizzleFried

  • Drama-Monger
  • Sr. Member
  • ****
  • Posts: 754
Re: Automatic Attachment Rotation
« Reply #2 on: March 14, 2016, 05:59:17 PM »
Not working... maybe the mod doesn't work with inline attachment mod?


Offline dougiefresh

  • SMF Hero
  • ******
  • Posts: 2,499
    • XPtsp.com Community
Re: Automatic Attachment Rotation
« Reply #3 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....)

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....
NOTICE:  My website is back up!

My Free Simple Machines mods on XPtsp.com, Simple Machines Customization Site, and at GitHub!
Problem uninstalling mods?  Try Arantor's Sortable Packages (and Installed Time) mod!  It's super helpful!

Offline FrizzleFried

  • Drama-Monger
  • Sr. Member
  • ****
  • Posts: 754
Re: Automatic Attachment Rotation
« Reply #4 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.


Offline dougiefresh

  • SMF Hero
  • ******
  • Posts: 2,499
    • XPtsp.com Community
Re: Automatic Attachment Rotation
« Reply #5 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....
NOTICE:  My website is back up!

My Free Simple Machines mods on XPtsp.com, Simple Machines Customization Site, and at GitHub!
Problem uninstalling mods?  Try Arantor's Sortable Packages (and Installed Time) mod!  It's super helpful!

Offline dan4ever

  • Jr. Member
  • **
  • Posts: 101
  • Gender: Male
  • SMF 2.0.11
Re: Automatic Attachment Rotation
« Reply #6 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
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



If you are looking for functionality to deal with existing attachments, then I can add that into the mod as well. 
YES, PLEASE!!!!!!!

/Dan
/Dan Ohlsson, Admin at http://www.guldforum.se

Offline dougiefresh

  • SMF Hero
  • ******
  • Posts: 2,499
    • XPtsp.com Community
Re: Automatic Attachment Rotation
« Reply #7 on: March 21, 2016, 07:12:41 PM »
No, still not working.
And I got alot of this error:

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

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....
NOTICE:  My website is back up!

My Free Simple Machines mods on XPtsp.com, Simple Machines Customization Site, and at GitHub!
Problem uninstalling mods?  Try Arantor's Sortable Packages (and Installed Time) mod!  It's super helpful!

Offline dan4ever

  • Jr. Member
  • **
  • Posts: 101
  • Gender: Male
  • SMF 2.0.11
Re: Automatic Attachment Rotation
« Reply #8 on: March 22, 2016, 09:29:28 AM »
No, still not working.
And I got alot of this error:

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

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
/Dan Ohlsson, Admin at http://www.guldforum.se

Offline dougiefresh

  • SMF Hero
  • ******
  • Posts: 2,499
    • XPtsp.com Community
Re: Automatic Attachment Rotation
« Reply #9 on: March 22, 2016, 06:47:07 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?
NOTICE:  My website is back up!

My Free Simple Machines mods on XPtsp.com, Simple Machines Customization Site, and at GitHub!
Problem uninstalling mods?  Try Arantor's Sortable Packages (and Installed Time) mod!  It's super helpful!

Offline dan4ever

  • Jr. Member
  • **
  • Posts: 101
  • Gender: Male
  • SMF 2.0.11
Re: Automatic Attachment Rotation
« Reply #10 on: March 24, 2016, 05:29:48 AM »
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
/Dan Ohlsson, Admin at http://www.guldforum.se

Offline dougiefresh

  • SMF Hero
  • ******
  • Posts: 2,499
    • XPtsp.com Community
Re: Automatic Attachment Rotation
« Reply #11 on: March 24, 2016, 08:50:02 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)....

For the Admin, moderator and the member how post it. Not for everybody!!!
Duh....  :P
NOTICE:  My website is back up!

My Free Simple Machines mods on XPtsp.com, Simple Machines Customization Site, and at GitHub!
Problem uninstalling mods?  Try Arantor's Sortable Packages (and Installed Time) mod!  It's super helpful!

Offline dan4ever

  • Jr. Member
  • **
  • Posts: 101
  • Gender: Male
  • SMF 2.0.11
Re: Automatic Attachment Rotation
« Reply #12 on: March 24, 2016, 08:56:18 PM »
OK
/Dan Ohlsson, Admin at http://www.guldforum.se

Offline dan4ever

  • Jr. Member
  • **
  • Posts: 101
  • Gender: Male
  • SMF 2.0.11
Re: Automatic Attachment Rotation
« Reply #13 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 
/Dan Ohlsson, Admin at http://www.guldforum.se

Offline dougiefresh

  • SMF Hero
  • ******
  • Posts: 2,499
    • XPtsp.com Community
Re: Automatic Attachment Rotation
« Reply #14 on: March 25, 2016, 08:18:54 AM »
Was thinking about doing something similar at the Profile -> Show Posts -> Attachments screen.....
NOTICE:  My website is back up!

My Free Simple Machines mods on XPtsp.com, Simple Machines Customization Site, and at GitHub!
Problem uninstalling mods?  Try Arantor's Sortable Packages (and Installed Time) mod!  It's super helpful!

Offline dougiefresh

  • SMF Hero
  • ******
  • Posts: 2,499
    • XPtsp.com Community
Re: Automatic Attachment Rotation
« Reply #15 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....

No, still not working.
And I got alot of this error:

Quote
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.....
« Last Edit: March 25, 2016, 06:53:01 PM by dougiefresh »
NOTICE:  My website is back up!

My Free Simple Machines mods on XPtsp.com, Simple Machines Customization Site, and at GitHub!
Problem uninstalling mods?  Try Arantor's Sortable Packages (and Installed Time) mod!  It's super helpful!

Offline dan4ever

  • Jr. Member
  • **
  • Posts: 101
  • Gender: Male
  • SMF 2.0.11
Re: Automatic Attachment Rotation
« Reply #16 on: May 23, 2016, 07:10:10 AM »
Hi, again


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


/Dan
/Dan Ohlsson, Admin at http://www.guldforum.se

Offline dan4ever

  • Jr. Member
  • **
  • Posts: 101
  • Gender: Male
  • SMF 2.0.11
Re: Automatic Attachment Rotation
« Reply #17 on: June 06, 2016, 07:12:13 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!!!!

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
/Dan Ohlsson, Admin at http://www.guldforum.se

Offline Rock Lee

  • Sophist Member
  • *****
  • Posts: 1,211
  • Gender: Male
  • Digitalizando un nuevo mundo :D
    • BomberCode.Oficial on Facebook
    • RockLee-BC on GitHub
    • @Bomber_Code on Twitter
    • Bomber Code ~ La nueva era del conocimiento
Re: Automatic Attachment Rotation
« Reply #18 on: June 07, 2016, 12:00:17 PM »
Very good @dougiefresh I see now modified afternoon I looked closer :)


Regards!
¡Regresando como cual Fenix! ~ Bomber Code © 2017
Ayudas - Aportes - Tutoriales - Y mucho mas!!!

Offline KungFuJoe

  • Semi-Newbie
  • *
  • Posts: 57
Re: Automatic Attachment Rotation
« Reply #19 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.