1. How do I read metadata from my JPEG files?

If your application is dependent on Dekoh Photo Application (read more here), you can make use of JPEG MetadataParser shipped with Dekoh Photo Application. This will read metadata from IPTC and EXIF block of JPEG file with precedence given to IPTC.

Given below is a sample code, which

import dekoh.photo.MetadataParser ;
import dekoh.photo.PhotoMetaData;


File picture = new File(“testfile”); //this is a jpeg file to be read

PhotoMetaData photoMetaData = null; //A dataobject produced after reading the IPTC and EXIF blocks from a JPEG file.
  try {
 photoMetaData=MetadataParser.getMetadataParser(picture).getPhotoMetaData();
 } catch (MetadataParseException e) {
      logger.logThrowable(e); //this may come if the provided file is not  a valid jpeg  file 
}
//

One can use this PhotoMetaData object to read name,description, capture date, city, state, sub location, country, tags, country code and photo EXIFOrientation.

2. How do I read metadata from my MP3 files?

If your application is dependent on Dekoh Music application, you can make use of MP3 metadataparser shipped with Dekoh Music Application. This will read metadata from the ID3 version 2 and ID3 version 1 with precedence given to ID3 version 2.
Sample code

import dekoh.music.importer.meta.MusicMetaData;
import dekoh.music.importer.meta.MetaDataParser;

File mp3File = new File(“testfile”); //This is a mp3 file to be read
MetaDataParser parser = new MetaDataParser();

MusicMetaData musicMetadata = parser.getMetaData(mp3File);// This will guess metadata if not found in mp3

MusicMetaData rawMusicMetadata = parser.getRawMetaData(mp3File);//This will read metadata as found in mp3 file. 

3. How do I import JPEG files?

If your application is dependent on Dekoh Photo Application (read more here), you can make use of PhotosExecuteImportHelper to import your pictures into the Dekoh database.
Sample code
DIOEntityManagerFactory dioEMF = new DIOEntityManagerFactory("dio-
persistence-unit", databaseProps); // this is just a sample code. Please see how to obtain DIOEntityManagerFactory in a Dekoh application

MetadataImportOptions metadataImportOptions = new MetadataImportOptions();

metadataImportOptions.setReadStandardMetadata(true);
//Making this variable to TRUE to make sure you don't loose IPTC data   while importing
//Making this variable to TRUE to will tell PhotoImportProcessor to derive
metadta based on the jpeg file name
metadataImportOptions.setDeriveMetadataFromFilename(true);

//Object to monitor the progress of import
ImportProgressObject importProgressObject = new ImportProgressObject();
	
File []dirsToImport=new File[]{dir1,dir2};//these are the directories you with to import

PhotosExecuteImportHelper.doImport(dioEMF, dirsToImport, importProgressObject, metadataImportOptions, true);
//

4.How do i upload pictures to a third party website or some online storage ?

TO upload pictures to a third party website or online storage, start by creating a tool for Dekoh Photos application.
  • Ensure that you specify the component type as "tool" in Dekoh's deployment description file called component.xml.

Sample code
<component enabled="true" xmlns="http://www.dekoh.com/xmlns/component" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://www.dekoh.com/xmlns/component 
http://www.dekoh.com/schemas/component.xsd">
    <id>Your Tools component Id</id>
    <version>1</version>
    <type>tool</type>
    <display-name>Tools Name</display-name>

  • Declare Dekoh Photos as the tools parent application in pramati-j2ee-server.xml

Sample code
<pramati-j2ee-server>
    <vhost-name>default</vhost-name>
    <auto-start>TRUE</auto-start>
    <deployment-properties>
        <!--<depends-on>photoshare.war</depends-on>-->
        <parent-app>
            <war>
                <vhost-name>default</vhost-name>
                <name>photos</name>
            </war>
        </parent-app>
    </deployment-properties>

  • Dekoh runtime will arrange the class loaders, such that the tool will have access to the classes defined by Dekoh Photos.
  • During the tool start up, register an implementation of dekoh.photo.publish.PhotoPublisher with PhotoPublisherRegistry.
  • You are now done. Your tool will now be listed as an option for users to use to publish photos.