Scaling and rotation of image without depending on EXIF data?
Is there such a thing as a simple image editor for Linux which allowed for scaling and rotating the image without using EXIF data for the scaling and rotation?
Saving Versus Export
I know you state you don’t really want to do this in GIMP, but in my experience the issue you are running into—software favoring EXIF orientation data over actually transforming pixels in the image—boils down to the difference between exporting an image and saving an image.
In the past, 100% all image editors in the world would actually transform/modify pixels when dealing with simple orientation transforms. It’s only relatively recently that image editing programs defer to using EXIF data to store some physical transformation data.
Why? Easy. Since the JPEG format is a lossy format—even when quality is set at 100%—resaving a JPEG for simple things like image rotation will slowly degrade the data. In contrast by storing that data as EXIF info, the raw JPEG image is left untouched but the transformation data is passed along so you can see the image rotated without degrading the image in the process.
This is where the export concept comes into play. Many image editing programs such as GIMP allow one to export an image which would basically mean modify the image data itself and optimize it for use in non-image editing software.
So while there might be other software tools that explicitly modify image data for tasks like rotation out there, it might be overkill to install and use them. Instead I would recommend simply experimenting with export functionality in whatever image editing software you are using; whether it be GIMP, Photoshop or something else.
Batch Processing
All that said, you do mention how GIMP might be too time consuming for your needs. Unclear what your exact workflow is, but if you have a folder/directory filled with JPEGs you might need to process, I would recommend investigating the tools mentioned in this other answer:
- exiftran: A tool used to transform digital camera JPEG images which can do the following:
It can do lossless rotations like jpegtran, but unlike jpegtran it cares about the EXIF data: It can rotate images automatically by checking the exif orientation tag, it updates the exif informaton if needed (image dimension, orientation), it also rotates the exif thumbnail. It can process multiple images at once.
- JHead: Specifically using
jhead
with the-autorot
option which is described as:
Using the 'Orientation' tag of the Exif header, rotate the image so that it is upright. The program 'jpegtran' is used to perform the rotation. This program is present in most Linux distributions. For windows, you need to get a copy of it. After rotation, the orientation tag of the Exif header is set to '1' (normal orientation). The Exif thumbnail is also rotated. Other fields of the Exif header, including dimensions are untouched, but the JPEG height/width are adjusted.
This feature is especially useful with newer digital cameras, which set the orientation field in the Exif header automatically using a built in orientation sensor in the camera.
Here is another tool mentioned in this other thread:
- NConvert: NConvert is the multi-format commandline image converter for Win32, Linux, DOS, OS/2, and other platforms. Quick-start details seem to be here. And it appears that if you use
nconvert
with the-jpegtrans
option that is exactly what you are looking for. But I wonder if that just uses the same library/core functionality ofjpegtran
as this other answer on this question recommends?
Finally, perhaps using the ImageMagick convert
tool with the -auto-orient
option would work for you?
-auto-orient
adjusts an image so that its orientation is suitable for viewing (i.e. top-left orientation).
This operator reads and resets the EXIF image profile setting 'Orientation' and then performs the appropriate 90 degree rotation on the image to orient the image, for correct viewing.
This EXIF profile setting is usually set using a gravity sensor in digital camera, however photos taken directly downward or upward may not have an appropriate value. Also images that have been orientation 'corrected' without reseting this setting, may be 'corrected' again resulting in a incorrect result. If the EXIF profile was previously stripped, the -auto-orient operator will do nothing.
I usually use jpegtran
to rotate photographs:
jpegtran -copy all -rotate 90 -outfile newimg.jpg oldimg.jpg
90 rotates right, use 270 for left (and 180 for flip).
When exporting in GIMP you can click Advanced in the popup just before saving where you can disable EXIF and XMP.
The overall algorithm to script it:
- For each file.
- Save value from
exiftool * | grep Orientation
. - Remove exif with
exiftran -ai *
. - Use
convert -rotate
with value from step 2.