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
Post by: dougiefresh on March 04, 2016, 07:34:59 PM
Link to Mod (https://custom.simplemachines.org/mods/index.php?mod=4087)


AUTOMATIC ATTACHMENT ROTATION v3.11
By Dougiefresh (http://www.simplemachines.org/community/index.php?action=profile;u=253913) -> Link to Mod (http://custom.simplemachines.org/mods/index.php?mod=4087)


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

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

Special Credit
This mod relies on the phpExifRW (http://www.phpclasses.org/package/1042-PHP-EXIF-information-reader-and-writer.html) class, which is licensed under the GNU Lesser General Public License (http://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 (http://www.galloway.me.uk/2012/01/uiimageorientation-exif-orientation-sample-images/) and at the  Image Orientation (http://www.elkarte.net/community/index.php?topic=2509.0) thread over at the ElkArte forum.

Changelog
The changelog has been removed and can be seen at XPtsp.com (http://www.xptsp.com/board/index.php?topic=662.msg975#msg975).

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.
Title: Re: Automatic Attachment Rotation
Post by: dougiefresh 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 (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....)

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



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

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

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

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

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
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
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
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)!


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

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
Ok...so now the rotate function is working.
Good to hear!

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

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


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

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

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

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

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

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
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
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
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
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
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
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
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=43bb26f24f284216d0509b1e72bcd488) (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=376ab02da06296cbfe027d5fd4e0dfc5) (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

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:
Code: [Select]
'href' => $scripturl . '?action=dlattach . ';ts=' . $time . ';topic=' . $msg_topic . '.0;attach=' . $attachment['id_attach'],
with:
Code: [Select]
'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
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
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
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:
Code: [Select]
$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:
Code: [Select]
$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).
Code: [Select]
$memoryLimit = (float) ini_get('memory_limit');
Title: Re: Automatic Attachment Rotation
Post by: dougiefresh on January 21, 2018, 08:27:51 PM
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
@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
@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
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:
Code: [Select]
$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:
Code: [Select]
<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!
Code: [Select]
$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)

Code: [Select]
$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
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:
Code: [Select]
$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:
Code: [Select]
<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:

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

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