Separate IPTC/EXIF buffers
This commit is contained in:
@@ -1226,19 +1226,27 @@ int ImageIO::saveJPEG (const Glib::ustring &fname, int quality, int subSamp) con
|
|||||||
|
|
||||||
jpeg_start_compress(&cinfo, TRUE);
|
jpeg_start_compress(&cinfo, TRUE);
|
||||||
|
|
||||||
// buffer for exif and iptc markers
|
// buffer for exif marker
|
||||||
unsigned char* buffer;
|
unsigned char* exifBuffer = nullptr;
|
||||||
unsigned int size;
|
unsigned int exifBufferSize = 0;
|
||||||
|
|
||||||
// assemble and write exif marker
|
// assemble and write exif marker
|
||||||
if (exifRoot) {
|
if (exifRoot) {
|
||||||
rtexif::ExifManager::createJPEGMarker (exifRoot, *exifChange, cinfo.image_width, cinfo.image_height, buffer, size);
|
rtexif::ExifManager::createJPEGMarker (exifRoot, *exifChange, cinfo.image_width, cinfo.image_height, exifBuffer, exifBufferSize);
|
||||||
|
|
||||||
if (size > 0 && size < 65530) {
|
if (exifBufferSize > 0 && exifBufferSize < 65530) {
|
||||||
jpeg_write_marker(&cinfo, JPEG_APP0 + 1, buffer, size);
|
jpeg_write_marker(&cinfo, JPEG_APP0 + 1, exifBuffer, exifBufferSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (exifBuffer != nullptr) {
|
||||||
|
delete [] exifBuffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
// buffer for iptc marker
|
||||||
|
unsigned char* iptcBuffer = new unsigned char[65535];
|
||||||
|
|
||||||
// assemble and write iptc marker
|
// assemble and write iptc marker
|
||||||
if (iptc) {
|
if (iptc) {
|
||||||
unsigned char* iptcdata;
|
unsigned char* iptcdata;
|
||||||
@@ -1254,7 +1262,7 @@ int ImageIO::saveJPEG (const Glib::ustring &fname, int quality, int subSamp) con
|
|||||||
|
|
||||||
int bytes = 0;
|
int bytes = 0;
|
||||||
|
|
||||||
if (!error && (bytes = iptc_jpeg_ps3_save_iptc (nullptr, 0, iptcdata, size, buffer, 65532)) < 0) {
|
if (!error && (bytes = iptc_jpeg_ps3_save_iptc (nullptr, 0, iptcdata, size, iptcBuffer, 65532)) < 0) {
|
||||||
error = true;
|
error = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1263,11 +1271,11 @@ int ImageIO::saveJPEG (const Glib::ustring &fname, int quality, int subSamp) con
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!error) {
|
if (!error) {
|
||||||
jpeg_write_marker(&cinfo, JPEG_APP0 + 13, buffer, bytes);
|
jpeg_write_marker(&cinfo, JPEG_APP0 + 13, iptcBuffer, bytes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
delete [] buffer;
|
delete [] iptcBuffer;
|
||||||
|
|
||||||
// write icc profile to the output
|
// write icc profile to the output
|
||||||
if (profileData) {
|
if (profileData) {
|
||||||
|
Reference in New Issue
Block a user