mirror of
https://github.com/lifegpc/pixiv_downloader.git
synced 2026-06-06 05:49:01 +08:00
Update exif module
This commit is contained in:
@@ -15,6 +15,8 @@ typedef struct ExifValue ExifValue;
|
||||
typedef struct ExifData ExifData;
|
||||
/// <div rustbindgen opaque></div>
|
||||
typedef struct ExifDatum ExifDatum;
|
||||
/// <div rustbindgen opaque></div>
|
||||
typedef struct ExifDataRef ExifDataRef;
|
||||
#if defined _WIN32 && defined WIN32_DLL
|
||||
#if BUILD_DLL
|
||||
#define EXIF_API __declspec(dllexport)
|
||||
@@ -26,6 +28,7 @@ typedef struct ExifDatum ExifDatum;
|
||||
#endif
|
||||
|
||||
EXIF_API ExifImage* create_exif_image(const char* path);
|
||||
EXIF_API const ExifDataRef* exif_image_get_exif_data(ExifImage* image);
|
||||
EXIF_API int exif_image_set_exif_data(ExifImage* image, ExifData* data);
|
||||
EXIF_API int exif_image_write_metadata(ExifImage* image);
|
||||
EXIF_API void free_exif_image(ExifImage* img);
|
||||
@@ -54,8 +57,10 @@ EXIF_API int64_t exif_value_to_int64(ExifValue* value, long i);
|
||||
EXIF_API ExifData* exif_data_new();
|
||||
EXIF_API int exif_data_add(ExifData* d, ExifKey* key, ExifValue* value);
|
||||
EXIF_API int exif_data_clear(ExifData* d);
|
||||
EXIF_API int exif_data_is_empty(ExifData* d);
|
||||
EXIF_API long exif_data_get_count(ExifData* d);
|
||||
EXIF_API const ExifDataRef* exif_data_get_ref(ExifData* d);
|
||||
EXIF_API ExifData* exif_data_ref_clone(ExifDataRef* d);
|
||||
EXIF_API int exif_data_ref_is_empty(ExifDataRef* d);
|
||||
EXIF_API long exif_data_ref_get_count(ExifDataRef* d);
|
||||
EXIF_API void exif_free_value(ExifValue* value);
|
||||
EXIF_API void exif_free_data(ExifData* d);
|
||||
EXIF_API void exif_free_datum(ExifDatum* d);
|
||||
|
||||
@@ -24,6 +24,12 @@ end:
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const ExifDataRef* exif_image_get_exif_data(ExifImage* image) {
|
||||
if (!image || !image->image) return nullptr;
|
||||
image->exif_data_ref.data = &image->image->exifData();
|
||||
return &image->exif_data_ref;
|
||||
}
|
||||
|
||||
int exif_image_set_exif_data(ExifImage* image, ExifData* data) {
|
||||
if (!image || !data) return 1;
|
||||
image->image->setExifData(data->data);
|
||||
@@ -230,14 +236,36 @@ int exif_data_clear(ExifData* d) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int exif_data_is_empty(ExifData* d) {
|
||||
if (!d) return -1;
|
||||
return d->data.empty() ? 1 : 0;
|
||||
const ExifDataRef* exif_data_get_ref(ExifData* d) {
|
||||
if (!d) return nullptr;
|
||||
d->ref.data = &d->data;
|
||||
return &d->ref;
|
||||
}
|
||||
|
||||
long exif_data_get_count(ExifData* d) {
|
||||
if (!d) return -1;
|
||||
return d->data.count();
|
||||
ExifData* exif_data_ref_clone(ExifDataRef* d) {
|
||||
if (!d || !d->data) return nullptr;
|
||||
auto n = new ExifData;
|
||||
if (!n) return nullptr;
|
||||
try {
|
||||
for (auto i = d->data->begin(); i != d->data->end(); ++i) {
|
||||
n->data.add(*i);
|
||||
}
|
||||
} catch (std::exception& e) {
|
||||
printf("%s\n", e.what());
|
||||
delete n;
|
||||
return nullptr;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
int exif_data_ref_is_empty(ExifDataRef* d) {
|
||||
if (!d || !d->data) return -1;
|
||||
return d->data->empty() ? 1 : 0;
|
||||
}
|
||||
|
||||
long exif_data_ref_get_count(ExifDataRef* d) {
|
||||
if (!d || !d->data) return -1;
|
||||
return d->data->count();
|
||||
}
|
||||
|
||||
void exif_free_value(ExifValue* value) {
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
#ifndef _EXIF_EXIF_PRIV_H
|
||||
#define _EXIF_EXIF_PRIV_H
|
||||
#include "exiv2/exiv2.hpp"
|
||||
typedef struct ExifDataRef {
|
||||
const Exiv2::ExifData* data = nullptr;
|
||||
} ExifDataRef;
|
||||
typedef struct ExifImage {
|
||||
Exiv2::Image::UniquePtr image;
|
||||
ExifDataRef exif_data_ref;
|
||||
} ExifImage;
|
||||
typedef struct ExifKey {
|
||||
Exiv2::ExifKey* key = nullptr;
|
||||
@@ -12,6 +16,7 @@ typedef struct ExifValue {
|
||||
} ExifValue;
|
||||
typedef struct ExifData {
|
||||
Exiv2::ExifData data;
|
||||
ExifDataRef ref;
|
||||
} ExifData;
|
||||
typedef struct ExifDatum {
|
||||
Exiv2::Exifdatum* data;
|
||||
|
||||
Reference in New Issue
Block a user