Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

Archived:Manipulating the EXIF data of a JPEG file using Symbian C++

From Wiki
Jump to: navigation, search

Archived.pngArchived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.


Article Metadata
Code ExampleCompatibility
Platform(s): S60 3rd Edition, S60 3rd Edition FP1
S60 3rd Edition FP1
S60 3rd Edition (initial release)
Article
Created: User:Technical writer 2 (November 22, 2006; updated March 25, 2008)
Last edited: hamishwillee (01 Jul 2012)

Overview

Manipulating the EXIF data of a JPEG file

Description

The CJPEGExifEncoder class is a part of Symbian's Image Conversion Library API and as the documentation clearly states, this API is not a part of the SDK (the required header file ICLExif.h is missing).
The EXIF API was introduced in S60 3rd Edition SDK and it consists of the following classes: CExifModify, CExifRead, CExifTag, and TExifTagInfo.
The code sequence below exemplifies how the above mentioned API can be used to update or create the EXIF data of a given *.jpg file.

Solution

 void CTest::UpdateExifL( const TFileName& aFileName )
{
RFs fsSession;
RFile rFile;
TInt fileSize = 0;
HBufC8* buff = NULL;
HBufC8* newExif = NULL;
CExifModify* modify = NULL;
TBool createNew = EFalse;
 
// Connect to the fileserver
User::LeaveIfError(fsSession.Connect());
CleanupClosePushL(fsSession);
User::LeaveIfError(rFile.Open( fsSession,
aFileName,
EFileRead ));
 
rFile.Size( fileSize );
buff = HBufC8::NewLC( fileSize);
TPtr8 tprBuff = buff->Des();
rFile.Read(tprBuff);
rFile.Close();
 
// Will leave with KErrCorrupt if EXIF info not valid
TRAPD( error, modify = CExifModify::NewL( tprBuff ) );
if(error == KErrCorrupt)
{
modify = CExifModify::NewL( tprBuff,
CExifModify::ECreate );
createNew = ETrue;
}
CleanupStack::PushL( modify );
 
// New EXIF structure must have all mandatory fields.
// See http://www.exif.org/Exif2-2.PDF
if( createNew )
{
CreateMandatoryTags(*modify);
}
 
// Modify particular fields as needed
modify->SetImageDescriptionL( _L8("TestS60App") );
modify->SetMakeL( _L8("Nokia S60") );
 
// WriteDataL will leave with KErrNotReady if
// mandatory tags not present
TRAP(error, newExif = modify->WriteDataL(tprBuff) );
if( error != KErrNotReady )
{
User::LeaveIfError( error );
}
 
if( error == KErrNone )
{
CleanupStack::PushL(newExif);
// Write valid EXIF structure
User::LeaveIfError(rFile.Replace( fsSession,
aFileName,
EFileWrite ));
rFile.Write( *newExif );
rFile.Close();
CleanupStack::PopAndDestroy( newExif );
}
else
{
// Do nothing if EXIF structure is incomplete
}
 
// Destroy loaded resources from the cleanup stack
// (modify, buff, fsSession)
CleanupStack::PopAndDestroy( 3, &fsSession );
}

An example project for modifying the EXIF data by adding geotags to images can be found File:GeoTagging Example.zip.

This page was last modified on 1 July 2012, at 12:23.
65 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×