[SCM] exiv2 packaging branch, master, updated. debian/0.25-3.1-3734-gdcbc29a
Maximiliano Curia
maxy at moszumanska.debian.org
Thu Jul 13 17:36:56 UTC 2017
Gitweb-URL: http://git.debian.org/?p=pkg-kde/kde-extras/exiv2.git;a=commitdiff;h=c56b79a
The following commit has been merged in the master branch:
commit c56b79acec417a2ccda18de14b3d5cef258f21d4
Author: brad <chickb at gmail.com>
Date: Wed Feb 2 21:10:23 2005 +0000
Added the ability to read and write to in-memory images.
---
msvc/exivsimple/exivsimple.cpp | 56 ++++++++++++++++++++++++++++++++++++++++--
msvc/exivsimple/exivsimple.h | 5 +++-
2 files changed, 58 insertions(+), 3 deletions(-)
diff --git a/msvc/exivsimple/exivsimple.cpp b/msvc/exivsimple/exivsimple.cpp
index 0f3ab69..b29dccb 100644
--- a/msvc/exivsimple/exivsimple.cpp
+++ b/msvc/exivsimple/exivsimple.cpp
@@ -38,8 +38,8 @@ struct ImageWrapper
Exiv2::Image::AutoPtr image;
};
-// Returns 0 if failed.
-EXIVSIMPLE_API HIMAGE OpenImage(const char *file)
+// Returns NULL (0) handle if failed.
+EXIVSIMPLE_API HIMAGE OpenFileImage(const char *file)
{
assert(file);
ImageWrapper *imgWrap = new ImageWrapper;
@@ -63,6 +63,25 @@ EXIVSIMPLE_API HIMAGE OpenImage(const char *file)
return (HIMAGE)imgWrap;
}
+EXIVSIMPLE_API HIMAGE OpenMemImage(const BYTE *data, unsigned int size)
+{
+ assert(data);
+ ImageWrapper *imgWrap = new ImageWrapper;
+
+ imgWrap->image = Exiv2::ImageFactory::open(data, size);
+ if (imgWrap->image.get() == 0) {
+ return 0;
+ }
+
+ // Load existing metadata
+ if (imgWrap->image->readMetadata()) {
+ delete imgWrap;
+ imgWrap = 0;
+ }
+
+ return (HIMAGE)imgWrap;
+}
+
EXIVSIMPLE_API void FreeImage(HIMAGE img)
{
if (img) {
@@ -71,6 +90,7 @@ EXIVSIMPLE_API void FreeImage(HIMAGE img)
}
}
+// Returns 0 on success
EXIVSIMPLE_API int SaveImage(HIMAGE img)
{
assert(img);
@@ -78,6 +98,34 @@ EXIVSIMPLE_API int SaveImage(HIMAGE img)
return imgWrap->image->writeMetadata();
}
+// Note that if you have modified the metadata in any way and want the
+// size of the image after these modifications, you must call SaveImage
+// before calling ImageSize.
+// Returns -1 on failure, otherwise the image size
+EXIVSIMPLE_API int ImageSize(HIMAGE img)
+{
+ assert(img);
+ ImageWrapper *imgWrap = (ImageWrapper*)img;
+ return imgWrap->image->io().size();
+}
+
+// Note that if you have modified the metadata in any way and want the
+// image data after these modifications, you must call SaveImage before
+// calling ImageData.
+// Returns number of bytes read, 0 if failure
+EXIVSIMPLE_API int ImageData(HIMAGE img, BYTE *buffer, unsigned int size)
+{
+ assert(img);
+ int result = 0;
+ ImageWrapper *imgWrap = (ImageWrapper*)img;
+ Exiv2::BasicIo &io = imgWrap->image->io();
+ if(io.open() == 0) {
+ result = imgWrap->image->io().read(buffer, size);
+ io.close();
+ }
+ return result;
+}
+
// This is weird because iptc and exif have not been "unified". Once
// they are unified, this DLL should not have to know
// about either... just generic images, keys, values, etc.
@@ -85,6 +133,7 @@ EXIVSIMPLE_API int SaveImage(HIMAGE img)
// buffsize should be the total size of *buff (including space for null)
// Note that if there is more than one entry (for some IPTC datasets) this
// returns the first one found. Currently no way to get the others.
+// Returns 0 on success
EXIVSIMPLE_API int ReadMeta(HIMAGE img, const char *key, char *buff, int buffsize)
{
assert(img && key && buff);
@@ -131,6 +180,7 @@ EXIVSIMPLE_API int ReadMeta(HIMAGE img, const char *key, char *buff, int buffsiz
// Overwrites existing value if found, otherwise creates a new one.
// Passing invalidTypeId causes the type to be guessed.
// Guessing types is accurate for IPTC, but not for EXIF.
+// Returns 0 on success
EXIVSIMPLE_API int ModifyMeta(HIMAGE img, const char *key, const char *val, DllTypeId type)
{
assert(img && key && val);
@@ -200,6 +250,7 @@ EXIVSIMPLE_API int ModifyMeta(HIMAGE img, const char *key, const char *val, DllT
// Always creates a new metadata entry.
// Passing invalidTypeId causes the type to be guessed.
// Guessing types is accurate for IPTC, but not for EXIF.
+// Returns 0 on success
EXIVSIMPLE_API int AddMeta(HIMAGE img, const char *key, const char *val, DllTypeId type)
{
assert(img && key && val);
@@ -254,6 +305,7 @@ EXIVSIMPLE_API int AddMeta(HIMAGE img, const char *key, const char *val, DllType
// If multiple entires exist, this only remove the first one
// found. Call multiple times to remove many.
+// Returns 0 on success
EXIVSIMPLE_API int RemoveMeta(HIMAGE img, const char *key)
{
assert(img && key);
diff --git a/msvc/exivsimple/exivsimple.h b/msvc/exivsimple/exivsimple.h
index cb85e3c..813277b 100644
--- a/msvc/exivsimple/exivsimple.h
+++ b/msvc/exivsimple/exivsimple.h
@@ -58,9 +58,12 @@ enum DllTypeId { invalidTypeId, unsignedByte, asciiString, unsignedShort,
typedef bool (CALLBACK* METAENUMPROC)(const char *key, const char *value, void *user);
-EXIVSIMPLE_API HIMAGE OpenImage(const char *file);
+EXIVSIMPLE_API HIMAGE OpenFileImage(const char *file);
+EXIVSIMPLE_API HIMAGE OpenMemImage(const BYTE *data, unsigned int size);
EXIVSIMPLE_API void FreeImage(HIMAGE img);
EXIVSIMPLE_API int SaveImage(HIMAGE img);
+EXIVSIMPLE_API int ImageSize(HIMAGE img);
+EXIVSIMPLE_API int ImageData(HIMAGE img, BYTE *buffer, unsigned int size);
EXIVSIMPLE_API int ReadMeta(HIMAGE img, const char *key, char *buff, int buffsize);
EXIVSIMPLE_API int EnumMeta(HIMAGE img, METAENUMPROC proc, void *user);
EXIVSIMPLE_API int AddMeta(HIMAGE img, const char *key, const char *val, DllTypeId type);
--
exiv2 packaging
More information about the pkg-kde-commits
mailing list