News:

Wondering if this will always be free?  See why free is better.

Main Menu

Automatic Attachment Rotation (and Resize)

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

Previous topic - Next topic

dougiefresh

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

dan4ever

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%]
/Dan Olsson, Webmaster at https://www.guldforum.se

dougiefresh

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



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

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

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

KungFuJoe

Quote from: dougiefresh on September 25, 2016, 10:37:23 PM
UPDATE:  Sorry about the delay in responding.  It took some work, along with a considerable amount of fiddling with the settings of my Apache/PHP/MySQL server that I was using in order to get my localhost forum to upload the image.  Once I did, the forum correctly rotated and/or flipped the image so that it was upright....

Hmmm...the pic doesn't rotate automatically on my site.  Do you think it could be an issue with missing a PHP class?

dougiefresh

Quote from: kungfujoe on September 26, 2016, 04:05:47 PM
Hmmm...the pic doesn't rotate automatically on my site.  Do you think it could be an issue with missing a PHP class?
I doubt it.  If there was a missing PHP class, the topic display wouldn't function.  Let me investigate this bug report.....

blunted

$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

dan4ever

Quote from: dougiefresh on September 26, 2016, 09:39:12 AM

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


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


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

dan4ever

Quote from: blunted on September 28, 2016, 10:07:06 PM
$txt['img_orientation'] = 'Rotate Clockwise'; $txt['img_orientation1'] = 'None'; $txt['img_orientation2'] = 'Horizontal Flip'; $txt['img_orientation3'] = 'Rotate 180°'; $txt['img_orientation4'] = 'Vertical Flip'; $txt['img_orientation5'] = 'Vertical Flip, Rotate 270°'; $txt['img_orientation6'] = 'Rotate 270°'; $txt['img_orientation7'] = 'Horizontal Flip, Rotate 270°'; $txt['img_orientation8'] = 'Rotate 90°';

getting this in admin


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


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

blunted

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

getting this in admin

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


/Dan

dougiefresh

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.

dougiefresh

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

dougiefresh

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.

dougiefresh

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.

KungFuJoe

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)

KungFuJoe

Also, the rotation appears to happen counter clockwise, not clockwise.

dougiefresh

Quote from: kungfujoe on January 13, 2017, 01:17:42 PM
I'm not sure if this is browser specific but when I edit a post to rotate an image...when I choose a rotation from the drop down, it will automatically uncheck the attachment.  If someone isn't aware of this and saves the modified post, it will delete the attachment.

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

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

Quote from: kungfujoe on January 13, 2017, 02:02:53 PM
Also, the rotation appears to happen counter clockwise, not clockwise.
I'm going to assume that you mean the image is rotated without you specifying the rotation value, since you haven't given me much to work on.  I can't reproduce this either.  If you change the rotation selection box and then click Post, of course it's going to rotate/flip the image in the direction specified.   That's by design.

KungFuJoe

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. 

dougiefresh

Post your Themes/default/Post.template.php, so I might be able to see what is happening....

landyvlad

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?

"Put as much effort into your question as you'd expect someone to give in an answer"

Please do not PM, IM or Email me with questions on astrophysics or theology.  You will get better and faster responses by asking homeless people in the street. Thank you.

Be the person your dog thinks you are.

dougiefresh

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

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

Advertisement: