View this post on Hive: Steemit Condenser Contributions: automatic photo rotation
Well this is actually a work done in the Steemit Image Hoster project but because you usually see the resulting data in the Condenser, I'll keep it as part of Condenser contributions.
When you upload an image on Steemit.com, your original image is hosted under a URL in the following format:
When you then access the image from the Condenser, it will not fetch the original image directly but will go through a proxy script that will download the original file, resize, compress and cache it under:
Now the issue this PR tries to fix is happening during the proxy processing phase.
When taking a photo using your mobile phone or tablet in portrait mode (holding the phone upside up), the device's camera does is actually taking the shot in landscape mode (upside to the left) and adds some metadata to the saved file. When you open the photo in the photos app, the app will read that metadata and will rotate the image before displaying it to you for viewing.
What this means is that whatever software (including the browser) is used to view that photo should also apply the rotation before display. But the image proxy app, during the image processing has removed the useful metadata and as a result, when you view the image in a blog post, the image being displayed has a wrong orientation.
Here is an example of the issue from Rest in peace dad rip @wales. My condolences to @trystan family for your loss.
The solution I've chose is not the best but it is the best for the moment. Ideally, I should make the code not strip the metadata out of the file during the processing of the image. However, those metadata sometimes include geolocation of where the photo has been taken and for safety reason I prefer them to not be included. So what I did is just perform a rotation when needed.
Maybe a future improvement would be to remove the auto-rotation and allow the metadata from the original file but filter out data that can be of user's safety concerns.
The fix was quite simple:
I took the opportunity to replace the use of deprecated method calls and also update the image processing library (Sharp) to a newer version that supports what I needed.
A quick test shows that it worked:
This feature is not out yet, a pull request has been created: https://github.com/steemit/imagehoster/pull/118.
The PR was approved and merged but the changes seem to have not been released yet but this is not something I can control so lets hope Steemit Inc will deploy soon.
Vote for my witness On Steem, Witnesses are playing the important role of providing a performant and safe network for all of us. You have the power to choose 30 trusty witnesses to package transactions and sign the blocks that will go in the Steem blockchain. Vote for me via SteemConnect to help me do more useful projects for the communities.
Congratulations @quochuy, you have received a 80% upvote. I'm the Vietnamese Community bot developed by witness @quochuy and powered by community SP delegations
GJ, all features you make a added to steemit?
Nice one @quochuy.. much needed.
I seem to vaguely remember it being theoretically possible to strip out everything but rotation data but at the time was too lazy to look more into it (mostly because I do it locally as part of a batch process). Might be something to look into if you're not already :)
Great work, this should benefit other frontends as well then since it's a contribution to imagehoster and not to condenser, right? Btw, the link to the pull request is wrong ;)
Thanks for sharing
Nice!!! Many of us needed this is the platform, me myself also encounters this problem as well.
Nice work, 😀👍💪
Very nice 👍
Posted using Partiko iOS