This question belongs on the User list. You may find more response there as there will be other Imaging users (as well as developers); please also use a descriptive subject line.
And note that Sanselan is now called Imaging On 29 March 2013 00:28, Randy Aldrich <rand...@gmail.com> wrote: > I've been researching ways to write tags to my images similar to how > Windows Live Photo Gallery works. I've played with several different > libraries (metadata-extractor,jhead,jheader,sanselan) but have only really > found Sanselan to accomodate writing the data back in that I need. > > I followed Apache's > WriteExifMetadataExample<http://commons.apache.org/proper/commons-imaging//xref-test/org/apache/sanselan/sampleUsage/WriteExifMetadataExample.html> > to > a T & It worked flawlessly for updating the GPS data and Aperture. > > I then attempted to modify the example to update EXIF_TAG_XPKEYWORDS rather > thanEXIF_TAG_APERTURE_VALUE. > > In the above-linked example, I replaced the TiffOutputField.create line > with the following: > > String currentTagsAsString = new String((byte[]) > jpegMetadata.findEXIFValue(ExifTagConstants.EXIF_TAG_XPKEYWORDS).getValue());System.out.println("current > tags: '" + currentTagsAsString + "'");String newTag = "h e l l > o";String newTagsAsString = currentTagsAsString.trim() + " ; " + > newTag + " ";System.out.println("new desired tags: '" + > newTagsAsString + "'");TiffOutputField keywords = new > TiffOutputField(ExifTagConstants.EXIF_TAG_XPKEYWORDS, > FieldType.FIELD_TYPE_BYTE, newTagsAsString.length(), > newTagsAsString.getBytes()); > exifDirectory.removeField(ExifTagConstants.EXIF_TAG_XPKEYWORDS); > exifDirectory.add(keywords); > > Other than commenting out the aperature and GPS update code, the rest I > left alone. I will admit the format of the byte array has me a little > confused so that may very well be the issue. > > I get no warnings/errors/etc. The process completes normally but the new > Image file does not contain the updated tags. Why does the new image not > contain the updated tags? Is there an easier/better way? > > I have found that my string formatting was a little off in my example > above. The actual encoding of the original byte array does not include > space characters, but instead the '0' byte. I have adjusted the code > accordingly still with no luck. > > Also, this E-mail is a direct copy of an existing stack overflow > question<http://stackoverflow.com/questions/15593707/writing-exif-xpkeywords-with-sanselan>which > I posed and has yet to yield any help. Feel free to answer the > stackoverflow question instead. > Randy Aldrich > http://randyaldrich.net --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org For additional commands, e-mail: dev-h...@commons.apache.org