[SCM] exiv2 packaging branch, master, updated. debian/0.25-3.1-3734-gdcbc29a
Maximiliano Curia
maxy at moszumanska.debian.org
Thu Jul 13 17:38:08 UTC 2017
Gitweb-URL: http://git.debian.org/?p=pkg-kde/kde-extras/exiv2.git;a=commitdiff;h=f381cb6
The following commit has been merged in the master branch:
commit f381cb6966e05ed0946cc178f01eb1e6c0cd5210
Author: Andreas Huggel <ahuggel at gmx.net>
Date: Sat Nov 25 15:38:38 2006 +0000
Do not write TIFF header to JPEG images if the Exif data is empty. Fixes bug #498.
---
src/exif.cpp | 8 ++++++--
src/exif.hpp | 5 ++++-
src/jpgimage.cpp | 26 ++++++++++++++------------
test/bugfixes-test.sh | 9 +++++++++
test/data/bugfixes-test.out | 9 +++++++++
5 files changed, 42 insertions(+), 15 deletions(-)
diff --git a/src/exif.cpp b/src/exif.cpp
index 7c6a700..f5be5c8 100644
--- a/src/exif.cpp
+++ b/src/exif.cpp
@@ -720,12 +720,16 @@ namespace Exiv2 {
}
// Allocate a data buffer big enough for all metadata
- long size = tiffHeader.size();
- size += ifd0.size() + ifd0.dataSize();
+ long size = ifd0.size() + ifd0.dataSize();
size += exifIfd.size() + exifIfd.dataSize();
size += iopIfd.size() + iopIfd.dataSize();
size += gpsIfd.size() + gpsIfd.dataSize();
size += ifd1.size() + ifd1.dataSize();
+
+ // Return an empty buffer without TIFF header if there is nothing to write
+ if (size == 0) return DataBuf(0);
+
+ size += tiffHeader.size();
DataBuf buf(size);
// Copy the TIFF header, all IFDs, MakerNote and thumbnail to the buffer
diff --git a/src/exif.hpp b/src/exif.hpp
index c93e0cd..ea242c4 100644
--- a/src/exif.hpp
+++ b/src/exif.hpp
@@ -511,7 +511,7 @@ namespace Exiv2 {
/*!
@brief Write the Exif data to a data buffer, which is returned. The
caller owns this copy and %DataBuf ensures that it will be
- deleted. The copied data starts with the TIFF header.
+ deleted. The copied data starts with the TIFF header.
Tries to update the original data buffer and write it back with
minimal changes, in a 'non-intrusive' fashion, if possible. In this
@@ -526,6 +526,9 @@ namespace Exiv2 {
the Exif data is updated with the metadata from the actual thumbnail
image (overriding existing metadata).
+ @note If there is no Exif data to write, the buffer is empty, i.e.,
+ no TIFF header is written in this case.
+
@return A %DataBuf containing the Exif data.
*/
DataBuf copy();
diff --git a/src/jpgimage.cpp b/src/jpgimage.cpp
index 354c4bd..58ffdb2 100644
--- a/src/jpgimage.cpp
+++ b/src/jpgimage.cpp
@@ -478,21 +478,23 @@ namespace Exiv2 {
--search;
}
if (exifData_.count() > 0) {
- // Write APP1 marker, size of APP1 field, Exif id and Exif data
DataBuf rawExif = exifData_.copy();
- tmpBuf[0] = 0xff;
- tmpBuf[1] = app1_;
+ if (rawExif.size_ > 0) {
+ // Write APP1 marker, size of APP1 field, Exif id and Exif data
+ tmpBuf[0] = 0xff;
+ tmpBuf[1] = app1_;
- if (rawExif.size_ + 8 > 0xffff) throw Error(37, "Exif");
- us2Data(tmpBuf + 2, static_cast<uint16_t>(rawExif.size_ + 8), bigEndian);
- memcpy(tmpBuf + 4, exifId_, 6);
- if (outIo.write(tmpBuf, 10) != 10) throw Error(21);
+ if (rawExif.size_ + 8 > 0xffff) throw Error(37, "Exif");
+ us2Data(tmpBuf + 2, static_cast<uint16_t>(rawExif.size_ + 8), bigEndian);
+ memcpy(tmpBuf + 4, exifId_, 6);
+ if (outIo.write(tmpBuf, 10) != 10) throw Error(21);
- // Write new Exif data buffer
- if ( outIo.write(rawExif.pData_, rawExif.size_)
- != rawExif.size_) throw Error(21);
- if (outIo.error()) throw Error(21);
- --search;
+ // Write new Exif data buffer
+ if ( outIo.write(rawExif.pData_, rawExif.size_)
+ != rawExif.size_) throw Error(21);
+ if (outIo.error()) throw Error(21);
+ --search;
+ }
}
if (psData.size_ > 0 || iptcData_.count() > 0) {
// Set the new IPTC IRB, keeps existing IRBs but removes the
diff --git a/test/bugfixes-test.sh b/test/bugfixes-test.sh
index 8b3455c..b47b11e 100755
--- a/test/bugfixes-test.sh
+++ b/test/bugfixes-test.sh
@@ -65,6 +65,15 @@ $binpath/largeiptc-test $filename ../data/imagemagick.png
num=495
filename=`prep_file $num`
$binpath/exiv2 -pi $filename
+
+num=498
+filename=exiv2-bug$num.jpg
+cp -f ../data/exiv2-empty.jpg $filename
+$binpath/exiv2 -v -M"set Exif.GPSInfo.GPSLatitude 0/1 1/1 2/1" $filename
+$binpath/exiv2 -v -pv $filename
+$binpath/exiv2 -v -M"del Exif.GPSInfo.GPSLatitude" $filename
+$binpath/exiv2 -v -pv $filename
+
) > $results 2>&1
if [ x"`which unix2dos.exe`" != x ]; then
diff --git a/test/data/bugfixes-test.out b/test/data/bugfixes-test.out
index bf687b0..f1b3286 100644
--- a/test/data/bugfixes-test.out
+++ b/test/data/bugfixes-test.out
@@ -251,3 +251,12 @@ Error: Upper boundary of the 1st data entry of IFD1 is out of bounds:
Iptc.Application2.Caption String 56 Die Insel Stromboli mit dem Vulkan Stromboli, 1000m hoch
Iptc.Application2.Program String 7 digiKam
Iptc.Application2.ProgramVersion String 11 0.9.0-beta3
+File 1/1: exiv2-bug498.jpg
+Set Exif.GPSInfo.GPSLatitude "0/1 1/1 2/1" (Rational)
+File 1/1: exiv2-bug498.jpg
+0x8825 Image GPSTag Long 1 26
+0x0002 GPSInfo GPSLatitude Rational 3 0/1 1/1 2/1
+File 1/1: exiv2-bug498.jpg
+Del Exif.GPSInfo.GPSLatitude
+File 1/1: exiv2-bug498.jpg
+exiv2-bug498.jpg: No Exif data found in the file
--
exiv2 packaging
More information about the pkg-kde-commits
mailing list