#1108 Added photoshop/iptc parser to png/jpeg parser.

v0.27.3
Robin Mills 9 years ago
parent 36b42eabeb
commit bdf8d3ad5b

@ -676,7 +676,8 @@ namespace Exiv2 {
bool bFlir = option == kpsRecursive && marker == (app0_+1) && std::strcmp(signature,"FLIR")==0;
bool bExif = option == kpsRecursive && marker == (app0_+1) && std::strcmp(signature,"Exif")==0;
bool bMPF = option == kpsRecursive && marker == (app0_+2) && std::strcmp(signature,"MPF")==0;
if( bFlir || bExif || bMPF ) {
bool bPS = option == kpsRecursive && std::strcmp(signature,"Photoshop 3.0")==0;
if( bFlir || bExif || bMPF || bPS ) {
// extract Exif data block which is tiff formatted
if ( size > 0 ) {
out << std::endl;
@ -717,14 +718,36 @@ namespace Exiv2 {
// << " index = " << pFFF->dwIndexOff << std::endl;
}
// create a copy on write memio object with the data, then print the structure
BasicIo::AutoPtr p = BasicIo::AutoPtr(new MemIo(exif+start,size-start));
if ( start < max ) TiffImage::printTiffStructure(*p,out,option,depth);
if ( bPS ) {
uint32_t i = 0 ;
byte* bytes = exif;
DataBuf dataBuf(bytes,size);
while ( i < size-3 && exif[i] != 0x1c ) i++;
depth++;
out << " Record | DataSet | Name | Length | Data" << std::endl;
while ( bytes[i] == 0x1c && i < size-3 ) {
char buff[100];
uint16_t record = bytes[i+1];
uint16_t dataset = bytes[i+2];
uint16_t len = getUShort(bytes+i+3,bigEndian);
sprintf(buff," %6d | %7d | %-24s | %6d | ",record,dataset, Exiv2::IptcDataSets::dataSetName(dataset,record).c_str(), len);
out << buff << Internal::binaryToString(dataBuf,len,i+5) << std::endl;
i += 5 + len;
}
depth--;
} else {
// create a copy on write memio object with the data, then print the structure
BasicIo::AutoPtr p = BasicIo::AutoPtr(new MemIo(exif+start,size-start));
if ( start < max ) TiffImage::printTiffStructure(*p,out,option,depth);
}
// restore and clean up
io_->seek(restore,Exiv2::BasicIo::beg);
delete [] exif;
bLF = false;
}
}
}

@ -34,6 +34,7 @@ EXIV2_RCSID("@(#) $Id$")
#ifdef EXV_HAVE_LIBZ
#include "pngchunk_int.hpp"
#include "image_int.hpp"
#include "pngimage.hpp"
#include "jpgimage.hpp"
#include "tiffimage.hpp"
@ -42,6 +43,7 @@ EXIV2_RCSID("@(#) $Id$")
#include "basicio.hpp"
#include "error.hpp"
#include "futils.hpp"
#include "types.hpp"
// + standard includes
#include <string>
@ -296,12 +298,23 @@ namespace Exiv2 {
out.write((const char*) dataBuf.pData_,dataBuf.size_);
}
if ( bIptc && bSoft ) { // we require a photoshop parser to recover IPTC data
const char* bytes = (const char*) dataBuf.pData_;
uint32_t l = (uint32_t) std::strlen(bytes)+2;
// create a copy on write memio object with the data, then print the structure
BasicIo::AutoPtr p = BasicIo::AutoPtr(new MemIo(dataBuf.pData_+l,dataBuf.size_-l));
TiffImage::printTiffStructure(*p,out,option,depth);
if ( bIptc ) {
const byte* bytes = dataBuf.pData_;
uint32_t l = (uint32_t) dataBuf.size_ ; // std::strlen(bytes)+2;
uint32_t i = 0 ;
depth++;
out << indent(depth) << "Record | DataSet | Name | Length | Data" << std::endl;
while ( bytes[i] == 0x1c && i < l-3 ) {
char buff[100];
uint16_t record = bytes[i+1];
uint16_t dataset = bytes[i+2];
uint16_t len = getUShort(bytes+i+3,bigEndian);
sprintf(buff,"%6d | %7d | %-24s | %6d | ",record,dataset, Exiv2::IptcDataSets::dataSetName(dataset,record).c_str(), len);
out << indent(depth) << buff << Internal::binaryToString(dataBuf,len,i+5) << std::endl;
i += 5 + len;
}
depth--;
}
}
delete [] data;

@ -423,6 +423,16 @@ source ./functions.source
runTest exiv2 -pC http://dev.exiv2.org/attachments/download/821/Reagan.tiff | cksum
runTest exiv2 -pC http://dev.exiv2.org/attachments/download/820/Reagan.jpg | cksum
num=1108
filename=exiv2-bug$num.xmp
printf "$num " >&3
echo '------>' Bug $num '<-------' >&2
copyTestFile imagemagick.png $filename
runTest exiv2 -pR $filename
copyTestFile $filename
runTest exiv2 -pR $filename
echo ''
num=1112
filename=exiv2-bug$num.xmp
printf "$num " >&3

Binary file not shown.

Binary file not shown.
Loading…
Cancel
Save