diff --git a/src/jpgimage.cpp b/src/jpgimage.cpp index a7979ffa..1f800a90 100644 --- a/src/jpgimage.cpp +++ b/src/jpgimage.cpp @@ -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; + } } } diff --git a/src/pngimage.cpp b/src/pngimage.cpp index 4ad97e2d..6b59645f 100644 --- a/src/pngimage.cpp +++ b/src/pngimage.cpp @@ -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 @@ -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; diff --git a/test/bugfixes-test.sh b/test/bugfixes-test.sh index f4bd1f6f..e1008bdb 100755 --- a/test/bugfixes-test.sh +++ b/test/bugfixes-test.sh @@ -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 diff --git a/test/data/bugfixes-test.out b/test/data/bugfixes-test.out index a454fed9..379e6042 100644 Binary files a/test/data/bugfixes-test.out and b/test/data/bugfixes-test.out differ diff --git a/test/data/exiv2-bug1108.exv b/test/data/exiv2-bug1108.exv new file mode 100644 index 00000000..185f9b15 Binary files /dev/null and b/test/data/exiv2-bug1108.exv differ