#1074 -pC now works on tiff files. Added test convenience targets to Makefile
This commit is contained in:
parent
4617dc3728
commit
d81e552cb7
33
Makefile
33
Makefile
@ -67,18 +67,33 @@ uninstall: config/config.mk
|
||||
doc: config/config.mk
|
||||
cd doc && $(MAKE) $(MAKECMDGOALS)
|
||||
|
||||
samples: config/config.mk
|
||||
cd samples && $(MAKE) $(MAKECMDGOALS)
|
||||
|
||||
tests:
|
||||
cd test && $(MAKE) test
|
||||
|
||||
teste testx testv:
|
||||
cd test && $(MAKE) $@
|
||||
|
||||
# exiv2 application and programs required by test suite
|
||||
exiv2 conntest exifprint remotetest:
|
||||
cd src && $(MAKE) $0
|
||||
|
||||
samples: config/config.mk
|
||||
cd samples && $(MAKE) $(MAKECMDGOALS)
|
||||
|
||||
# test suite
|
||||
tests:
|
||||
cd test && $(MAKE) test
|
||||
|
||||
# test suite sub groups
|
||||
teste testx testv:
|
||||
cd test && $(MAKE) $@
|
||||
|
||||
# convenience for running individual tests
|
||||
bugfixes-test.sh crw-test.sh curliotest.sh eps-preview-test.sh eps-test.sh exifdata-test.sh \
|
||||
exiv2-test.sh httpiotest.sh imagetest.sh iotest.sh iptctest.sh modify-test.sh \
|
||||
path-test.sh preview-test.sh sshiotest.sh stringto-test.sh tiff-test.sh video-test.sh \
|
||||
write-test.sh write-video-test.sh write2-test.sh xmpparser-test.sh :
|
||||
cd test && ./$@
|
||||
|
||||
# convenience target for running bugfixes-test.sh
|
||||
bugtest bugstest testbugs bugfixes:
|
||||
cd test && ./bugfixes-test.sh
|
||||
|
||||
# convenience target for building individual sample programs
|
||||
addmoddel exifcomment exifvalue httptest iptctest mmap-test stringto-test \
|
||||
exifdata iotest key-test path-test taglist write2-test write-test \
|
||||
convert-test exifdata-test exiv2json iptceasy largeiptc-test prevtest tiff-test \
|
||||
|
||||
@ -315,7 +315,7 @@ c : JPEG comment
|
||||
.br
|
||||
p : list available image previews, sorted by preview image size in pixels
|
||||
.br
|
||||
C : print image ICC Profile (jpg and png only)
|
||||
C : print image ICC Profile (jpg, png, tiff only)
|
||||
.br
|
||||
R : print image structure recursively (jpg, png, tiff only)
|
||||
.br
|
||||
|
||||
@ -444,6 +444,10 @@ namespace Exiv2 {
|
||||
{
|
||||
return type == 700 && option == kpsXMP;
|
||||
}
|
||||
static bool isPrintICC(uint16_t type, Exiv2::PrintStructureOption option)
|
||||
{
|
||||
return type == 0x8773 && option == kpsIccProfile;
|
||||
}
|
||||
|
||||
#define MIN(a,b) ((a)<(b))?(b):(a)
|
||||
|
||||
@ -463,9 +467,6 @@ namespace Exiv2 {
|
||||
throw Error(15);
|
||||
}
|
||||
|
||||
if ( option == kpsIccProfile ) {
|
||||
throw Error(13, io_->path());
|
||||
}
|
||||
io_->seek(0,BasicIo::beg);
|
||||
|
||||
printTiffStructure(io(),out,option,depth-1);
|
||||
@ -486,16 +487,20 @@ namespace Exiv2 {
|
||||
uint16_t dirLength = byteSwap2(dir,0,bSwap);
|
||||
|
||||
bool tooBig = dirLength > 200 ;
|
||||
bool bPrint = option == kpsBasic || option == kpsRecursive;
|
||||
|
||||
if ( bFirst && (option == kpsBasic || option == kpsRecursive) ) {
|
||||
if ( bFirst && bPrint ) {
|
||||
out << indent(depth) << Internal::stringFormat("STRUCTURE OF TIFF FILE (%c%c): ",c,c) << io.path() << std::endl;
|
||||
if ( tooBig ) out << indent(depth) << "dirLength = " << dirLength << std::endl;
|
||||
}
|
||||
|
||||
// Read the dictionary
|
||||
for ( int i = 0 ; !tooBig && i < dirLength ; i ++ ) {
|
||||
if ( bFirst )
|
||||
out << indent(depth) << " address | tag | type | count | offset | value\n";
|
||||
if ( bFirst && bPrint ) {
|
||||
out << indent(depth)
|
||||
<< " address | tag | "
|
||||
<< " type | count | offset | value\n";
|
||||
}
|
||||
bFirst = false;
|
||||
|
||||
io.read(dir.pData_, 12);
|
||||
@ -504,23 +509,23 @@ namespace Exiv2 {
|
||||
uint32_t count = byteSwap4(dir,4,bSwap);
|
||||
uint32_t offset = byteSwap4(dir,8,bSwap);
|
||||
|
||||
std::string sp = "" ; // output spacer
|
||||
std::string sp = "" ; // output spacer
|
||||
|
||||
//prepare to print the value
|
||||
uint16_t kount = isPrintXMP(tag,option) ? count // restrict long arrays
|
||||
: isStringType(type) ? (count > 32 ? 32 : count)
|
||||
: count > 5 ? 5
|
||||
: count
|
||||
;
|
||||
uint32_t pad = isStringType(type) ? 1 : 0;
|
||||
uint32_t size = isStringType(type) ? 1
|
||||
: is2ByteType(type) ? 2
|
||||
: is4ByteType(type) ? 4
|
||||
: 1
|
||||
;
|
||||
uint32_t Offset = 0 ; // used by ExifTag == 0x8769 && MakerNote == 0x927c to locate an FID
|
||||
uint16_t kount = isPrintXMP(tag,option) ? count // restrict long arrays
|
||||
: isPrintICC(tag,option) ? count //
|
||||
: isStringType(type) ? (count > 32 ? 32 : count)
|
||||
: count > 5 ? 5
|
||||
: count
|
||||
;
|
||||
uint32_t pad = isStringType(type) ? 1 : 0;
|
||||
uint32_t size = isStringType(type) ? 1
|
||||
: is2ByteType(type) ? 2
|
||||
: is4ByteType(type) ? 4
|
||||
: 1
|
||||
;
|
||||
|
||||
// if ( offset > io.size() ) offset = 0;
|
||||
// if ( offset > io.size() ) offset = 0; // Denial of service?
|
||||
DataBuf buf(MIN(size*kount + pad,48)); // allocate a buffer
|
||||
if ( isStringType(type) || count*size > 4 ) { // data is in the directory => read into buffer
|
||||
size_t restore = io.tell(); // save
|
||||
@ -531,12 +536,13 @@ namespace Exiv2 {
|
||||
std::memcpy(buf.pData_,dir.pData_+8,12);
|
||||
}
|
||||
|
||||
if ( option == kpsBasic || option == kpsRecursive ) {
|
||||
uint32_t Offset = isLongType(type) ? byteSwap4(buf,0,bSwap) : 0 ;
|
||||
|
||||
if ( bPrint ) {
|
||||
uint32_t address = start + 2 + i*12 ;
|
||||
out << indent(depth)
|
||||
<< Internal::stringFormat("%8u | %#06x %-25s |%10s |%9u |%9u | "
|
||||
,address,tag,tagName(tag,25),typeName(type),count,offset);
|
||||
|
||||
if ( isShortType(type) ){
|
||||
for ( uint16_t k = 0 ; k < kount ; k++ ) {
|
||||
out << sp << byteSwap2(buf,k*size,bSwap);
|
||||
@ -545,7 +551,6 @@ namespace Exiv2 {
|
||||
} else if ( isLongType(type) ){
|
||||
for ( uint16_t k = 0 ; k < kount ; k++ ) {
|
||||
out << sp << byteSwap4(buf,k*size,bSwap);
|
||||
if ( k == 0 ) Offset = byteSwap4(buf,k*size,bSwap) ;
|
||||
sp = " ";
|
||||
}
|
||||
} else if ( isRationalType(type) ){
|
||||
@ -564,6 +569,7 @@ namespace Exiv2 {
|
||||
} else if ( isStringType(type) ) {
|
||||
out << sp << Internal::binaryToString(buf, kount);
|
||||
}
|
||||
|
||||
sp = kount == count ? "" : " ...";
|
||||
out << sp << std::endl;
|
||||
if ( option == kpsRecursive
|
||||
@ -579,6 +585,9 @@ namespace Exiv2 {
|
||||
buf.pData_[count]=0;
|
||||
out << (char*) buf.pData_;
|
||||
}
|
||||
if ( isPrintICC(tag,option) ) {
|
||||
out.write((const char*)buf.pData_,buf.size_);
|
||||
}
|
||||
}
|
||||
io.read(dir.pData_, 4);
|
||||
start = tooBig ? 0 : byteSwap4(dir,0,bSwap);
|
||||
@ -593,7 +602,7 @@ namespace Exiv2 {
|
||||
|
||||
void TiffImage::printTiffStructure(BasicIo& io, std::ostream& out, Exiv2::PrintStructureOption option,int depth)
|
||||
{
|
||||
if ( option == kpsBasic || option == kpsXMP || option == kpsRecursive ) {
|
||||
if ( option == kpsBasic || option == kpsXMP || option == kpsRecursive || option == kpsIccProfile ) {
|
||||
// buffer
|
||||
const size_t dirSize = 32;
|
||||
DataBuf dir(dirSize);
|
||||
|
||||
@ -414,6 +414,15 @@ source ./functions.source
|
||||
copyTestFile $filename
|
||||
runTest exiv2 -pa -g zone $filename
|
||||
|
||||
num=1074
|
||||
filename=exiv2-bug$num.jpg
|
||||
printf "$num " >&3
|
||||
echo '------>' Bug $num '<-------' >&2
|
||||
copyTestFile imagemagick.png $filename
|
||||
runTest exiv2 -pC $filename | wc
|
||||
runTest exiv2 -pC http://dev.exiv2.org/attachments/download/821/Reagan.tiff | wc
|
||||
runTest exiv2 -pC http://dev.exiv2.org/attachments/download/820/Reagan.jpg | wc
|
||||
|
||||
num=1112
|
||||
filename=exiv2-bug$num.xmp
|
||||
printf "$num " >&3
|
||||
|
||||
Binary file not shown.
Loading…
Reference in New Issue
Block a user