News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Automatic Attachment Rotation (and Resize)

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

Previous topic - Next topic

dan4ever

Quote from: dan4ever on May 23, 2016, 07:10:10 AM
Hi, again


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


/Dan


The problem is still here...


/Dan
/Dan Olsson, Webmaster at https://www.guldforum.se

dougiefresh

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

dan4ever

/Dan Olsson, Webmaster at https://www.guldforum.se

dougiefresh

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

dougiefresh

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!

dougiefresh

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.

KungFuJoe

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!

dougiefresh

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!

KungFuJoe

Quote from: dougiefresh on September 20, 2016, 04:16:12 PM
Uploaded v2.1 - September 20th, 2016
o Fixed unknown column error in Display.php that occurs when thumbnails are disabled.




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

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

Parse error: syntax error, unexpected '(' in /home2/yandc/public_html/test.xxxxx.net/Sources/Subs-AutoRotation.php on line 193

KungFuJoe

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.

dougiefresh

#30
Uploaded v2.2 - September 20th, 2016
o Fixed syntax error found in Subs-AutoRotation.php.  Thanks, kungfujoe!



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

($row['thumb_rotation'])

Do you see the same on your end?  When I remove them, it seems to work.  But just want to make sure I'm not screwing something up.
@kungfujoe:  Yeah, I looked at the code real closely and saw that.  I can't believe I missed that....   Thanks for reporting the bug!

KungFuJoe

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.

KungFuJoe

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

dougiefresh

#33
Revised v2.2 - September 20th, 2016
o Fixed syntax error found in Subs-AutoRotation.php.  Thanks, kungfujoe!
o Fixed issue in the attachment screen, where attachment IDs were not being sent correctly.
o Fixed undefined index error in Subs-AutoRotation.php.
o Added forgotten package instruction to run add_remove_hooks.php during package operations.




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

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

KungFuJoe

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.

KungFuJoe

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?

dougiefresh

Quote from: kungfujoe on September 21, 2016, 12:56:23 AM
Ok...so now the rotate function is working.
Good to hear!

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

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

Quote from: kungfujoe on September 21, 2016, 12:56:23 AM
Are users able to rotate their own images or can it only be done from within the admin console?
Currently, it can only be done within the admin console.  I'll add some more stuff so that regular users can rotate their own images.....

KungFuJoe

If I attach the image here won't this forum just strip out the EXIF information?

Perhaps I could email you?

dougiefresh

#38
Quote from: kungfujoe on September 22, 2016, 02:53:00 PM
If I attach the image here won't this forum just strip out the EXIF information?

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

EDIT: I did some testing using images from GitHub 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.

dougiefresh

#39
@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

Advertisement: