Scaling and rotation of image without depending on EXIF data?

10

2

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?

So far have I tried EOG, Shotwell, and GIMP and when I rotate the images, they store it in the EXIF header. This I don't want.

Even if GIMP could do it, it is much too time consuming as it requires tons of mouse clicks when dealing with JPEG files.

Jasmine Lognnes

Posted 2015-08-31T11:55:13.980

Reputation: 263

2So basically, if you rotate an image 90 degrees to the left you want the image itself to be rotated in the data 90 degrees to the left? Not via info stored in the EXIF data, correct? – JakeGould – 2015-08-31T12:06:04.003

Exactly. I need that because Github README.md files doesn't understand EXIF. – Jasmine Lognnes – 2015-08-31T12:07:56.537

Bingo! I posted a fuller answer, but I believe the issue you are running into is the fundamental difference between saving an image in a modern image editing program versus exporting an image. My answer goes into more detail, but I believe if you were to export a JPEG via GIMP you will get the exact results you want without having to deal with EXIF data being favored for transforms like scaling and rotation. – JakeGould – 2015-08-31T12:23:19.067

Using GIMP's export on an exif stripped jpeg added a new one. – Jasmine Lognnes – 2015-08-31T13:14:27.063

Yes, it might have added new EXIF data, but was the actual image data changed to match orientation as your question asked? – JakeGould – 2015-08-31T13:35:23.637

Answers

15

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

JakeGould

Posted 2015-08-31T11:55:13.980

Reputation: 38 217

It would be perfect if a commandline tool could do the actual pixel rotation based on EXIF and then clear the EXIF info afterwards. Is that possible? – Jasmine Lognnes – 2015-08-31T13:12:22.600

1@JasmineLognnes I haven’t actually used any of these tools myself—but this question is a good reference for tools I should investigate—but it seems to me that exiftran and jpegtran might be what you are looking for. I would experiment with the options both of those tools have and see what happens. Best I can do. Good luck! – JakeGould – 2015-08-31T13:25:01.543

1You might find it humorous that the system selected this answer as an audit test in the LQ Post review queue. I voted to not delete it, BTW, and apparently, that was the right answer. :-) – fixer1234 – 2015-09-06T20:00:06.297

@fixer1234 Yeah, I saw that myself when I checked low quality posts earlier. Hilarious! It might have been triggered by the amount of various links to disparate packages I am recommended. But hey! I am happy there is some automated policing mechanism that at least has a human filtering component. – JakeGould – 2015-09-06T20:02:51.843

2

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

choroba

Posted 2015-08-31T11:55:13.980

Reputation: 14 741

2

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

d2xdt2

Posted 2015-08-31T11:55:13.980

Reputation: 171

This is exactly what I was looking for. A way that detects if the image is rotated and then a way to rotate it based on that. Thanks! – xarlymg89 – 2018-04-24T09:27:19.200

0

You can use Exiftool to remove EXIF data from JPEG images.

SPRBRN

Posted 2015-08-31T11:55:13.980

Reputation: 5 185

Yes, it is great for that, but when I edit the images afterwards, then new EXIF headers are added. – Jasmine Lognnes – 2015-08-31T13:00:11.043

EXIFTool can remove the data, but it won’t alter, rotate or scale and image. It will just wipe that data away and the JPEG will then display in whatever raw format it originally existed in. This is useful in some cases, but not in a case like this. – JakeGould – 2015-08-31T13:02:11.410