Skip to content

Commit

Permalink
Switched metadata assignment within input image classes to use more e…
Browse files Browse the repository at this point in the history
…fficient map insert() syntax
  • Loading branch information
ruven committed Jun 29, 2024
1 parent 0d16fc3 commit 70080cc
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 16 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
29/06/2024:
- Updated autoconf tiff m4 to search for tiffio.h rather than just tiff.h when using TIFFOpen().
- Switched metadata assignment within input image classes to use more efficient map insert() syntax.


29/05/2024:
Expand Down
4 changes: 2 additions & 2 deletions src/KakaduImage.cc
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ void KakaduImage::loadImageInfo( int seq, int ang )
// Extract any ICC profile and add it to our metadata map
int icc_length = 0;
const char* icc = (const char*) j2k_colour.get_icc_profile( &icc_length );
if( icc_length > 0 ) metadata["icc"] = string( icc, icc_length );
if( icc_length > 0 ) metadata.insert( {"icc",string(icc,icc_length)} );


// Set our colour space - we let Kakadu automatically handle CIELAB->sRGB conversion for the time being
Expand Down Expand Up @@ -408,7 +408,7 @@ void KakaduImage::loadImageInfo( int seq, int ang )
kdu_byte *buffer = new kdu_byte[xmp_size];
int nb = box.read( &buffer[0], xmp_size );
// Store this as XMP data
if( nb > 0 ) metadata["xmp"] = string( (const char*) buffer, nb );
if( nb > 0 ) metadata.insert( {"xmp",string((const char*)buffer,nb)} );
delete[] buffer;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/OpenJPEGImage.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* IIPImage Server: OpenJPEG JPEG2000 handler
Copyright (C) 2019-2023 Ruven Pillay.
Copyright (C) 2019-2024 Ruven Pillay.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -478,7 +478,7 @@ void OpenJPEGImage::process( unsigned int res, int layers, int xoffset, int yoff
// Extract any ICC profile - unfortunately, can only get ICC profile after decoding
int icc_length = _image->icc_profile_len;
const char* icc = (const char*) _image->icc_profile_buf;
if( icc_length > 0 ) metadata["icc"] = string( icc, icc_length );
if( icc_length > 0 ) metadata.insert( {"icc",string(icc,icc_length)} );
#ifdef OPENJPEG_DEBUG
if( icc_length > 0 ){
logfile << "OpenJPEG :: ICC profile detected with size " << icc_length << endl;
Expand Down
24 changes: 12 additions & 12 deletions src/TPTImage.cc
Original file line number Diff line number Diff line change
Expand Up @@ -314,21 +314,21 @@ void TPTImage::loadImageInfo( int seq, int ang )
delete[] default_max;

// Also get some basic metadata
if( TIFFGetField( tiff, TIFFTAG_ARTIST, &tmp ) ) metadata["creator"] = tmp;
if( TIFFGetField( tiff, TIFFTAG_COPYRIGHT, &tmp ) ) metadata["rights"] = tmp;
if( TIFFGetField( tiff, TIFFTAG_DATETIME, &tmp ) ) metadata["date"] = tmp;
if( TIFFGetField( tiff, TIFFTAG_IMAGEDESCRIPTION, &tmp ) ) metadata["description"] = tmp;
if( TIFFGetField( tiff, TIFFTAG_DOCUMENTNAME, &tmp ) ) metadata["title"] = tmp;
if( TIFFGetField( tiff, TIFFTAG_PAGENAME, &tmp ) ) metadata["pagename"] = tmp;
if( TIFFGetField( tiff, TIFFTAG_SOFTWARE, &tmp ) ) metadata["software"] = tmp;
if( TIFFGetField( tiff, TIFFTAG_MAKE, &tmp ) ) metadata["make"] = tmp;
if( TIFFGetField( tiff, TIFFTAG_MODEL, &tmp ) ) metadata["model"] = tmp;
if( TIFFGetField( tiff, TIFFTAG_XMLPACKET, &count, &tmp ) ) metadata["xmp"] = string(tmp,count);
if( TIFFGetField( tiff, TIFFTAG_ICCPROFILE, &count, &tmp ) ) metadata["icc"] = string(tmp,count);
if( TIFFGetField( tiff, TIFFTAG_ARTIST, &tmp ) ) metadata.insert( {"creator",tmp} );
if( TIFFGetField( tiff, TIFFTAG_COPYRIGHT, &tmp ) ) metadata.insert( {"rights",tmp} );
if( TIFFGetField( tiff, TIFFTAG_DATETIME, &tmp ) ) metadata.insert( {"date",tmp} );
if( TIFFGetField( tiff, TIFFTAG_IMAGEDESCRIPTION, &tmp ) ) metadata.insert( {"description",tmp} );
if( TIFFGetField( tiff, TIFFTAG_DOCUMENTNAME, &tmp ) ) metadata.insert( {"title",tmp} );
if( TIFFGetField( tiff, TIFFTAG_PAGENAME, &tmp ) ) metadata.insert( {"pagename",tmp} );
if( TIFFGetField( tiff, TIFFTAG_SOFTWARE, &tmp ) ) metadata.insert( {"software",tmp} );
if( TIFFGetField( tiff, TIFFTAG_MAKE, &tmp ) ) metadata.insert( {"make",tmp} );
if( TIFFGetField( tiff, TIFFTAG_MODEL, &tmp ) ) metadata.insert( {"model",tmp} );
if( TIFFGetField( tiff, TIFFTAG_XMLPACKET, &count, &tmp ) ) metadata.insert( {"xmp",string(tmp,count)} );
if( TIFFGetField( tiff, TIFFTAG_ICCPROFILE, &count, &tmp ) ) metadata.insert( {"icc",string(tmp,count)} );
if( TIFFGetField( tiff, TIFFTAG_STONITS, &scale ) ){
char buffer[32];
snprintf( buffer, sizeof(buffer), "%g", scale );
metadata["scale"] = buffer;
metadata.insert( {"scale",buffer} );
}
}

Expand Down

0 comments on commit 70080cc

Please sign in to comment.