Igor Kromin |   Consultant. Coder. Blogger. Tinkerer. Gamer.

It's been over a year since I released the last version of jPhotoFrame. Lately I had a few issues with some photos not rotating correctly so I decided to add an image rotation utility and release a minor update to jPhotoFrame. So version 0.3.1 is now available to download from GitHub.

The source code is of course still in the same spot - https://github.com/ikromin/jphotoframe.
I've now released verision 0.4 - please refer to this article - jPhotoFrame version 0.4 released with a whole new layout engine.


This release addresses the issue of incorrectly rotated JPEGs. This can happen when you hold your camera/phone in an unusual orientation while taking a photo. Since the orientation of the data inside the JPEG and how the image is meant to be displayed do not always match, it's possible to get some images being displayed with incorrect rotation. Most modern tools take care of this orientation mismatch for you so it's usually not noticeable. You can learn about this more here.

However, because jPhotoFrame is just using vanilla Java code to load and display JPEGs it was doing things like this sometimes...
IMG_0424.jpg


Oops! That particular image should have been rotated by 90 degrees to the right.



Based on this and with the aid of the mediautil library I put together a small utility to recursively fix image orientation for all JPEGs in a directory. This utility scans the entire directory and all of its subdirectories, tries to load any JPEGs it finds and if the orientation needs adjustment, it rotates the image data to a standard orientation and overwrites the original file.

The output looks something like this...
 Output
Reading file - /Personal/tmp/photos/20170211_152556.jpg
EXIF data found in image
Transforming image to correct orientation
Frame, precision 8
X= 1024, Y= 768
Components 3 (/Personal/tmp/photos/20170211_152556.jpg)
Size in MCU 64x48
0x51dd8(335320) byte(s) read in 20170211_152556.jpg
Writing image to disk


The end result is correctly oriented images!

Running this utility is a matter of running the fixrotation.sh script or doing something like this...
 Command
java -Xms128m -Xmx256m -jar jphotoframe.jar -fixrotation /Personal/tmp/photos


Here the directory name is /Personal/tmp/photos. As mentioned earlier this utility will attempt to fix all JPEGs in this directory and all of its subdirectories.

I ran this on a few hundred images and it runs pretty fast and so far has worked quite well. Don't forget to look at the README and download the latest version 0.3.1 package here.

-i

Did you like this post or found it useful? Considering supporting this Blog to keep its web servers running, any amount helps! Thanks!
Have comments or feedback on what I wrote? Please share them below!
comments powered by Disqus
Other posts you may like...