Uploaded image for project: 'Commons Imaging'
  1. Commons Imaging
  2. IMAGING-77

Typesafe, high-level API for setting EXIF fields

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 0.94-incubator
    • 1.0-alpha1
    • Format: TIFF
    • None
    • all

    Description

      The current EXIF API is extremely awkward to use.

      I. API is not typesafe and poorly documented.
      Currently you have two options:
      1) Pass values for EXIF tags as java.lang.Object (TiffOutputField.create)
      2) Pass values for EXIF tags as byte arrays (new TiffOutputField())
      In the first case, there is no way of knowing what kind of Object is required except looking at the sanselan source or using reflection.
      In the second case, a large part of the implementation of the EXIF specification remains with the client.
      Even if one uses the Object-based API one has to pass around byteorders and needs to null-terminate strings, which is something that would typically be handled by the library layer and not by the client.
      A usable API should throw a compile time error when a value is passed that has an incorrect type. This can be achieved either by subclassing TiffOutputField or by using generics.

      II. Code clarity
      A TiffOutputField is essentially nothing more than a TagInfo + a value. Than why don't you have a constructor TiffOutputField(TagInfo tag, bytes) ?
      Instead you need to do:
      new TiffOutputField(tag, tag.dataTypes[0], tag.length, bytes);

      III. Code correctness
      Most of e. g. the GPS tags simply do not work:
      GPS_TAG_GPS_VERSION_ID: TiffOutputField.create() fails with ImageWriteException
      GPS_TAG_GPS_MAP_DATUM: TiffOutputField.create() fails b/o bug Sanselan-12
      GPS_TAG_GPS_ALTITUDE_REF: TiffOutputField.create() fails b/o length -1
      GPS_TAG_GPS_ALTITUDE: TiffOutputField.create() fails b/o length -1
      GPS_TAG_GPS_DATE_STAMP: TiffOutputField.create() fails b/o bug Sanselan-12
      This is not 0.94 code quality but 0.01.

      Attachments

        Activity

          People

            Unassigned Unassigned
            winlumski Lulu winlumski
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: