Skip to content

The IT Blog

IT, Tech, Data, …

  • Home
  • Blog
    Thoughts about IT, Data, Work Culture
  • HowTos
    Stuff that was hard to find but very helpfull.
  • Research
    Posts from my research activities during my University time
  • About
  • GitHub
  • RSS
  • Mastodon

Imagero: EXIF Rotation Tag schreiben

Mit Imagero 329 hat folgender Java Code seltsamerweise eine NullpointerException geliefert. Mit der aktuellen Imagero Version 429 kann man das EXIF-Rotations Tag problemlos schreiben und damit JPEGs verlostlos und schnell drehen. Mit (oder bis) Version 423 wurde unter bestimmten Umständen das Orientation Tag doppelt geschrieben.

IOParameterBlock iopb = new IOParameterBlock(src);
iopb.setDestination(src);
JpegFile reader = (JpegFile) new ImageProcOptions(iopb).imageFile;
ExifApp1 app1 = (ExifApp1) reader.jmr.getMarker(ExifApp1.NAME, 0);
if (app1 == null) { // falls das Bild noch keine EXIF Daten enthält
    EXIF exif = new EXIF(new ImageFileDirectory());
    exif.set.orientation(Orientation.TOP_LEFT);
    MetadataUtils.insert(reader, new Marker[]{exif.createMarker()}, iopb);
} else { // Falls schon EXIF Daten im Bild sind
    app1.getExif().set.orientation(Orientation.TOP_LEFT);
    reader.saveImage(iopb);
}
iopb.close();

Orientation.TOP_LEFT steht dabei für die Ausrichtung. Zum Drehen sind die folgenden Werte relevant:

  • 0°: Orientation.TOP_LEFT
  • 180°: Orientation.BOTTOM_RIGHT
  • 90°: Orientation.RIGHT_TOP
  • 270°: Orientation.LEFT_BOTTOM

Daneben gibt es noch 4 weitere Werte, die das Bild entsprechend drehen und spiegeln:

  1        2       3      4         5            6           7          8

888888  888888      88  88      8888888888  88                  88  8888888888
88          88      88  88      88  88      88  88          88  88      88  88
8888      8888    8888  8888    88          8888888888  8888888888          88
88          88      88  88
88          88  888888  888888

Wobei 1-8 derart definiert ist:

The orientation of the camera relative to the scene, when the image was captured. The relation of the ‘0th row’ and ‘0th column’ to visual position is shown as below.

Value 0th Row 0th Column
1 top left side
2 top right side
3 bottom right side
4 bottom left side
5 left side top
6 right side top
7 right side bottom
8 left side bottom

Relavante Links:

  • Exif Spezifikation
  • jpegcrop Seite mit nützlichen Infos
  • JPEG Rotation and EXIF Orientation

JPEG Rotation and EXIF Orientation

Posted on 3. January 2011Author FranzCategories JavaTags Bild, EXIF, Image, Imagero, Java, metadata

Post navigation

Previous Previous post: Epson Perfection 1240U mit Windows7 64bit und Windows 10
Next Next post: GoogleMail: Dateianhänge aus E-Mails löschen
Imprint Proudly powered by WordPress