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

mucknet

Quote from: GL700Wing on March 22, 2022, 07:44:09 AM1.  Image resizing happens automatically when you save a post with an uploaded image (options are only shown for SMF 2.0 if you have configured different options for some membergroups and you have one of those membergroups as your Primary membergroup - for SMF 2.1 information is shown indicating the JPEG quality and maximum width/height that will be used);
3.  If uploaded JPEG images have the orientation EXIF information in their metadata they will be rotated automatically when the post is saved; and
2.  The option to manually rotate images (and now thumbs) has only ever been shown when you edit an existing message.


Thanks. That's really helpful. I've confirmed it is indeed working as expected then. Images are getting resized when they upload, which is the thing I cared about. I tried some images that need rotation, and they weren't auto rotated, but I'm not to worried about that. It's probably a use case I am not familiar with. The image resize was the main thing I was after. I'm actually happy there's no additional user facing UI for image resize/rotate because I can experiment with other themes, without worrying about messing this feature up.

Thanks for the great mod. Have a good one.

gevv

ElkArte is a modern, powerful community building forum software. https://www.elkarte.net/

mucknet

Hi @GL700Wing -- Would you consider adding an option to this mod to remove privacy related exif data? (ie: GPS data) I looked for another mod to do this, but don't see an option. I tried the "extensive security checks" option, but I couldn't find a single image I have that would upload without getting an error, and I couldn't find any documentation about what it actually does.


P.S. I had ASS-U-ME'd that the "Re-encode potentionally dangerous image attachments" would remove exiff data, but I was clearly wrong.

GL700Wing

Quote from: mucknet on March 24, 2022, 01:06:32 PMWould you consider adding an option to this mod to remove privacy related exif data? (ie: GPS data)
Sure - although having already looked into what's involved it'll probably be easier to remove all EXIF data (with the exception of colour profile stuff if iMagick is used) from JPEG images

QuoteP.S. I had ASS-U-ME'd that the "Re-encode potentionally dangerous image attachments" would remove exiff data, but I was clearly wrong.
That's core SMF code and I don't know which image attachments are considered to be potentially dangerous ...
Life doesn't have to be perfect to be wonderful ...

Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

FrizzleFried

One of my users has a question....

Quote2) When I rotate images using the cool new rotate image feature on my PC it works great. But if I go look at that same post on my phone, it is still sideways there.

...is this a bug?  I do not do mobile personally so I can't test it myself.


GL700Wing

Quote from: FrizzleFried on March 27, 2022, 12:53:43 PMOne of my users has a question....

Quote2) When I rotate images using the cool new rotate image feature on my PC it works great. But if I go look at that same post on my phone, it is still sideways there.

...is this a bug?  I do not do mobile personally so I can't test it myself.


It's a browser caching issue which I have a workaround for in the next release - see https://www.simplemachines.org/community/index.php?msg=4117126

In the meantime, if the user clears the browser cache for the forum on the affected computer/device the rotated image/thumbnail will be correctly displayed.
Life doesn't have to be perfect to be wonderful ...

Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

Sir Osis of Liver

#366
Installed this on a 2.0.19 forum in php 7.4.  Doesn't rotate all sideways pics off phones.  Used it once before and vaguely remember that if mod doesn't detect EXIF coding it displays option to manually rotate image.  That's not happening.

n/m, I see how it works.  Have to post the image first, if it posts sideways you have to 'Modify', then it displays select menu to rotate it and repost.

Sideways pics attached.
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

GL700Wing

Version v6.12 - v6.13 - April 22, 2022
o Per sts_pro - fixed caching issue of latest image/thumbnail not always being displayed by browser after being rotated.
o Per mucknet - added option to remove EXIF data from JPEG files.
o Fixed issue of non-JPEG images not being converted to JPEG if 'Reformat non-JPEG images to JPEG' option was enabled.
o Added support to enable members of Additional Membergroups membergroup IDs to use different resizing options which were introduced for Primary Membergroup and Post Count Based Group membergroup IDs in V5.10.
o SMF 2.1: Reinstated image/thumbnail view for rotating images while editing a message (accidentally disabled in v6.12).
o SMF 2.0: Added mod upgrade options for v6.10, v6.11 and v6.12.
o SMF 2.1: Added mod upgrade options for v6.12.
Life doesn't have to be perfect to be wonderful ...

Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

@rjen

Just installed the mod on SMF2.1 and I still do not see the option to manually rotate images when editing posts..

SMF 2.1: Reinstated image/thumbnail view for rotating images while editing a message (accidentally disabled in v6.12)

I can rotate and resize from the filemanager in the admin screen, but not when posting or editing posts. Am I missing something?

You cannot view this attachment.

I also noticed some errors in the dutch translation... find attached an update...

You cannot view this attachment.

Running SMF 2.1 with latest TinyPortal at www.fjr-club.nl

GL700Wing

Quote from: @rjen on April 22, 2022, 05:47:45 PMJust installed the mod on SMF2.1 and I still do not see the option to manually rotate images when editing posts..

SMF 2.1: Reinstated image/thumbnail view for rotating images while editing a message (accidentally disabled in v6.12)

I can rotate and resize from the filemanager in the admin screen, but not when posting or editing posts. Am I missing something?
For SMF 2.1 I couldn't work out how to add the manual rotate options to the standard message edit window so I added a 'Image Rotation' option to the 'More ...' drop-down menu instead (it openly appears for messages that have image attachments).

You cannot view this attachment.

Life doesn't have to be perfect to be wonderful ...

Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

GL700Wing

#370
Version v6.14 - April 27, 2022
o Per @rjen - updated Dutch language files for Auto Rotation.
o Fixed 'Undefined index: thumb_mime' error reported by FrizzleFried.


Notes
For SMF 2.0 forums using versions 6.10 through 6.13 there are upgrade options to version 6.14 - it is not necessary to uninstall these versions (ie, 6.10 through 6.13) beforehand.

For SMF 2.1 forums using versions 6.12 or 6.13 there are upgrade options to version 6.14 - it is not necessary to uninstall these versions (ie, 6.12 or 6.13) beforehand.
Life doesn't have to be perfect to be wonderful ...

Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

FrizzleFried

Interested in these "upgrade options" so I don't have to uninstall.  How does that work exactly?  Just install over the top of the old?

GL700Wing

#372
Quote from: FrizzleFried on April 27, 2022, 08:08:36 AMInterested in these "upgrade options" so I don't have to uninstall.  How does that work exactly?  Just install over the top of the old?
Not very many mods use the upgrade option because it is quite a bit more work for a mod developer to setup and test but if the upgrade process does not encounter any issues during the installation phase it makes the process of upgrading a mod much quicker and easier than having to uninstall and reinstall a mod (especially if one or both of these processes involves manual file edits).

I've done a lot of work and testing in relation to the upgrade process for this mod because either the changes to core SMF files between one version and a later version were only minor, because only the core mod files (eg, ./Sources/Subs-AutoRotation.php, ./Sources/Subs-ResizeExistingImages.php, and/or language files) needed to be updated, or sometimes it was a bit of both ...


Upgrade Process
1. Upload mod file
You cannot view this attachment.

2. Click on 'Browse Packages' to see if there is an 'Upgrade' option
You cannot view this attachment.

3. If there is an upgrade path from the currently installed version to the version you just uploaded you will see the 'Upgrade' option
You cannot view this attachment.

4.  Click on the 'Upgrade' option and, if no errors are reported, click on 'Install Now'
You cannot view this attachment.

If any installation errors are reported you must resolve these by either making the manual file edits required or by uninstalling the currently installed version and installing the version you just uploaded.
Life doesn't have to be perfect to be wonderful ...

Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

FrizzleFried

Holy smokes... i've been using SMF for well over a decade now... my last forum was a mod nightmare with TONS AND TONS of mods... and I have NEVER ONCE come across a situation where there was an "upgrade" button available.

> Mind Blown <

NOW... I wonder how many times over those (literally) hundreds of mods there WOULD have been if I had not uninstalled the mod prior to even attempting to upload the new...

Thank you for the detailed explanation!

GL700Wing

Quote from: FrizzleFried on April 27, 2022, 09:46:16 AMHoly smokes... i've been using SMF for well over a decade now... my last forum was a mod nightmare with TONS AND TONS of mods... and I have NEVER ONCE come across a situation where there was an "upgrade" button available.

> Mind Blown <

NOW... I wonder how many times over those (literally) hundreds of mods there WOULD have been if I had not uninstalled the mod prior to even attempting to upload the new...

Thank you for the detailed explanation!

I've been using SMF for almost 15 years, I have three forums with between 110 and 140 mods each (only a handful of which I've written) and I've only ever seen one mod with an upgrade option (and I used that to teach myself how to implement the upgrade option) ...

'tis a rare beast because it takes more time and effort for a mod developer to implement an upgrade option than the simpler uninstall/install path ...
Life doesn't have to be perfect to be wonderful ...

Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

Arantor

I've written 100+ mods for SMF in the last 13 years. I implemented upgrade once, the whole experience was so awful I never attempted it again.

Kudos to you for keeping the faith.
Holder of controversial views, all of which my own.

FrizzleFried

One last dumb question... I assume I can DELETE the old version now... but I wanted to confirm that assumption before just doing it.

:D


sah62

I just installed this mod on a forum running SMF 2.0.19 and I noticed multiple errors like these in the error log:

https://www.mysite.com/smf/index.php?topic=81046.0
2: touch(): Utime failed: Operation not permitted
File: /var/www/mysite/smf/Sources/Subs-AutoRotation.php
Line: 1180

https://www.mysite.com/smf/index.php?topic=81046.0
2: touch(): Utime failed: Operation not permitted
File: /var/www/mysite/smf/Sources/Subs-AutoRotation.php
Line: 613

Any thoughts on the cause? I'm thinking it's a file permission/ownership issue, but how can I eliminate the errors?

GL700Wing

Quote from: FrizzleFried on April 27, 2022, 10:20:55 AMOne last dumb question... I assume I can DELETE the old version now... but I wanted to confirm that assumption before just doing it.
Yep - go for it!

You don't need the older version(s) because if you uninstall the mod the end result in terms of the core SMF files and hook calls in the database will be the exactly same as if you hadn't used an upgrade option (ie, the uninstall process will reverse all the code changes the currently installed version of the mod would have made if the install process had been used - it is not a downgrade).
Life doesn't have to be perfect to be wonderful ...

Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

GL700Wing

Quote from: sah62 on April 27, 2022, 03:44:03 PMAny thoughts on the cause? I'm thinking it's a file permission/ownership issue, but how can I eliminate the errors?
It is a file permission/ownership issue and you can suppress the error messages by inserting @ before each of the six 'touch' commands in ./Sources/Subs-AutoRotation.php.

Find:
touch(
Replace with
@touch(
Making this change won't prevent you form uninstalling or upgrading this version of the mod in the future and I'll fix this issue in the next release.
Life doesn't have to be perfect to be wonderful ...

Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

Advertisement: