title: Apache Commons Imaging (EXIF): Setting tags/tags missing
body: <p>I'm using the Apache Commons Imaging <a href="http://commons.apache.org/proper/commons-imaging/index.html" rel="nofollow noreferrer">library</a> (Java 8, you can find my code <a href="https://stackoverflow.com/q/57710245/2016165">here</a>) and I've come across a few problems with tags:</p>
  
  <p>If I open the image info of e.g. <a href="http://de.web.img2.acsta.net/r_640_360/newsv7/18/05/08/19/22/3380658.jpg" rel="nofollow noreferrer">this</a> .jpg file with Win 10, there are "Origin" tags, e.g. "Authors" and "Date acquired":</p>
  
  <p><a href="https://i.stack.imgur.com/scpv0.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/scpv0.jpg" alt="enter image description here"></a></p>
  
  <p>You can find a list of EXIF tags <a href="https://sno.phy.queensu.ca/~phil/exiftool/TagNames/EXIF.html" rel="nofollow noreferrer">here</a> and it includes the "Authors" one and also an additional "Artist" one. The "Artist" tag seemed to have existed in the library at one point (<a href="https://commons.apache.org/proper/commons-imaging/apidocs/src-html/org/apache/commons/imaging/formats/tiff/constants/TiffTagConstants.html" rel="nofollow noreferrer">source</a>) but the <a href="https://commons.apache.org/proper/commons-imaging/apidocs/org/apache/commons/imaging/formats/tiff/constants/ExifTagConstants.html" rel="nofollow noreferrer">apidocs</a> don't list it anymore and <code>ExifTagConstants.TIFF_TAG_ARTIST</code> doesn't exist. Same thing with the "GPSAltitude" tag: It should exist according to the EXIF list but I can't seem to find it in the library.</p>
  
  <p>I tried to use the "Maker" tag instead:</p>
  
  <pre><code>final TiffOutputDirectory exifDir = outputSet.getOrCreateExifDirectory();
  exifDir.removeField(ExifTagConstants.EXIF_TAG_MAKER_NOTE);
  exifDir.add(ExifTagConstants.EXIF_TAG_MAKER_NOTE, "Test Maker");
  </code></pre>
  
  <p>But <code>ExifTagConstants.EXIF_TAG_MAKER_NOTE</code>'s type of <code>TagInfoUndefineds</code> doesn't seem to be valid for <code>exifDir.add</code>.</p>
  
  <p>I also tried to add the date:</p>
  
  <pre><code>exifDir.removeField(ExifTagConstants.EXIF_TAG_DATE_TIME_DIGITIZED);
  exifDir.add(ExifTagConstants.EXIF_TAG_DATE_TIME_DIGITIZED, "1970/01/01");
  </code></pre>
  
  <p>This just throws an exception:</p>
  
  <blockquote>
    <p>org.apache.commons.imaging.ImageWriteException: Tag expects 20 byte(s), not 1</p>
  </blockquote>
  
  <p>The only tag I've managed to successfully write so far is <code>ExifTagConstants.EXIF_TAG_USER_COMMENT</code>.</p>
  
  <p>How do I use/write these tags (author/artist, date, altitude,...)?</p>
  
  <p><strong><em>Edit:</em></strong></p>
  
  <p>I managed to find two of the tags:</p>
  
  <pre><code>exifDir.add(MicrosoftTagConstants.EXIF_TAG_XPAUTHOR, "Test Author");//Author
  exifDir.add(GpsTagConstants.GPS_TAG_GPS_ALTITUDE, new RationalNumber(3, 1));//Altitude
  </code></pre>
  
  <p>... but they aren't written into the file.</p>
  
  <pre><code>exifDir.add(ExifTagConstants.EXIF_TAG_USER_COMMENT, "my comment");
  </code></pre>
  
  <p>works, so I know it's actually writing tags, it just doesn't work for the two above. Any idea what's wrong?</p>