I've also considered the metadata interfaces we use, and I am not sure
the current approaches are any good.

Most metadata formats are designed in a way specific to that format,
eg. some have arbitrary levels of nesting, others have a flat
structure, etc. But most are designed to be stored in any image
format.

So instead of a Imaging.getMetadata() method that tries to unify all
metadata into one common interface - and does so badly, because eg.
EXIF can have nested subdirectories and this information is lost -
maybe we should have:
Imaging.getExifMetadata()
Imaging.getIptcMetadata()
Imaging.getXmpMetadata()

Regards
Damjan

On Tue, Jul 3, 2012 at 9:19 PM, Farrukh Najmi
<farr...@wellfleetsoftware.com> wrote:
>
> Updated proposed patch with following new changes:
>
> Add getValue() method to nested class IImageMetadataItem. These return the
> value of the item as an Object allowing for values of various types to be
> returned.
>
>
> On 07/03/2012 11:01 AM, Farrukh Najmi wrote:
>
> Moving this thread to dev list as it seems to be more appropriate there....
>
> Attached is a patch to the IImageMetadata.java that reflects my revised
> proposal thinking this through in conjunction with the proposed solution in
> another thread...
>
> Add a getMetadataSpecification() method to IImageMetadata so we can manage
> the metadata specification that defines the metadata
> Add getMetadata() to nested class IImageMetadataItem to get back at the
> parent IImageMetadata instance so we can access the metadata specification
> information managed from an IImageMetadata instance
> Add getId(), getName(), getDescription() methods to nested class
> IImageMetadataItem. These are the key triplet of info about the metadata
> item that is needed in my experience
>
> Of course implementations of these two interfaces would need to also be
> updated to support the new methods according to proposed semantics. I would
> be happy to contribute in any way that I can and as requested.
>
> Dev team colleagues, please weigh in on the proposal. Thanks for your
> awesome work to create this project and for considering this proposal.
>
> On 07/02/2012 07:12 PM, Farrukh Najmi wrote:
>
>
> Here is a proposed change to the API that would help my scenario...
>
> Modify the org.apache.commons.imaging.common.ImageMetadata$Item class to
> have the following additional methods:
>
> getMetadataSpecification() method that returns a constant String such as
> "IPTC:1.1", "EXIF:2.1", "EXIF:2.2"
> getId() method that returns a unique id as follows:
>
> For EXIF return the Field Name as in Table 3 TIFF Rev. 6.0 Attribute
> Information Used in Exif in the Exif spec.
> For IPTC return the IptcRecord..iptcType.getType()
>
> This would allow the first code pattern below to identify each item based on
> a specific metadata field defined by a specific specification.
>
> Thoughts?
>
> On 07/02/2012 06:18 PM, Farrukh Najmi wrote:
>
>
> Hi Guys,
>
> I am trying to use commons-imaging latest svn bits to write a program that
> will read standard metadata such as Exif and IPTC from images in a variety
> of image formats using code that is as image format neutral as possible. The
> goal is to store each class of metadata (e.g. Exif, IPTC, ...) in a separate
> Map where the key ide
>
>
> --
> Regards,
> Farrukh
>
> Web: http://www.wellfleetsoftware.com
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
> For additional commands, e-mail: dev-h...@commons.apache.org
>
> ntifies a metadata attribute identifier defined by the standard and a value
> that is the metadata attribute's value.
>
> Here are two patterns I have identified for reading the metadata by looking
> at test programs and code....
>
> 1. Read metadata items without considering image format or metadata
> standard.
>
>             IImageMetadata metadata = Imaging.getMetadata(is, "Oregon
> Scientific DS6639 - DSC_0307 - iptc added with irfanview.jpg");
>             List<? extends IImageMetadata.IImageMetadataItem> items =
> metadata.getItems();
>
>             int i=0;
>             for (IImageMetadata.IImageMetadataItem iitem : items) {
>                 ImageMetadata.Item item = (ImageMetadata.Item)iitem;
>                 System.err.println("Index: " + i + " Key: " +
> item.getKeyword() + " Value: " + item.getText() + " class: " +
> iitem.getClass());   //common.ImageMetadata$Item, Tiff.TiffImageMetadata
>                 i++;
>             }
>
>
> This is closest to what I want. The EXIF metadata is represented by
> org.apache.commons.imaging.formats.tiff.TiffImageMetadata$Item and I can get
> at the TiffField and its tagName and value (good). However, IPTC metadata is
> represented by org.apache.commons.imaging.common.ImageMetadata$Item. This
> class seems to have no link back to the
> org.apache.commons.imaging.formats.jpeg.iptc.IptcRecord and thus I cannot
> find a way to get the attribute defined by the IPTC spec under the IIM
> mapping rows.
>
>
> 2. Read Exif and IPTC separately using following metadata and image format
> specific  patterns as shown below...
>
>             //Read EXIF
>             JpegImageMetadata metadata = (JpegImageMetadata)
> Imaging.getMetadata(is, "Oregon Scientific DS6639 - DSC_0307 - iptc added
> with irfanview.jpg");
>             TiffImageMetadata exifMetadata = metadata.getExif();
>             List<TiffField> fields = exifMetadata.getAllFields();
>
>             int i=0;
>             for (TiffField field : fields) {
>                 String key = field.getTagName();
>                 Object value = field.getValue();
>                 String fieldName = field.tagInfo.name;
>                 System.err.println("Index: " + i + " Key: " + key + ",
> Value: " + value + ", valueType: " + value.getClass());
>                 i++;
>             }
>
>             //Read IPTC
>             JpegImageMetadata metadata = (JpegImageMetadata)
> Imaging.getMetadata(is, "Oregon Scientific DS6639 - DSC_0307 - iptc added
> with irfanview.jpg");
>             JpegPhotoshopMetadata psMetadata = metadata.getPhotoshop();
>             List oldRecords = psMetadata.photoshopApp13Data.getRecords();
>
>             for (int j = 0; j < oldRecords.size(); j++) {
>                 IptcRecord record = (IptcRecord) oldRecords.get(j);
>                 System.err.println("Key: " + record.iptcType.getName() + "
> (0x"
>                             + Integer.toHexString(record.iptcType.getType())
>                             + "), value: " + record.value);
>             }
>
> Above gives me all the linkage back to specification defined metadata fields
> but is less desirable because it metadata and image format specific.
>
> I feel that it would be ideal to support a generic api that is agnostic to
> metadata and image format but provides a reference back to the specification
> defined field (attribute) identifier some how.
>
> I would very much appreciate some ideas from dev team on how we could
> improve the api to support providing a reference back to a specification
> defined field in a metadata and image format neutral manner.
>
> My apologies if I am missing an obvious solution while I am getting familiar
> with the code.
>
>
>
>
> --
> Regards,
> Farrukh
>
> Web: http://www.wellfleetsoftware.com
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
> For additional commands, e-mail: dev-h...@commons.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org

Reply via email to