Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update exiv2 to 0.28 #135

Merged
merged 5 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
matrix:
os: [ubuntu-22.04]
python_version: [3.7, 3.8, 3.9, '3.10', '3.11', '3.12']
exiv2_version: [0.27.7]
exiv2_version: [0.28.1]
runs-on: ${{matrix.os}}
env:
PLATFORM_NAME: linux
Expand Down Expand Up @@ -88,7 +88,7 @@ jobs:
matrix:
os: [macos-12]
python_version: [3.6, 3.7, 3.8, 3.9, '3.10', '3.11', '3.12']
exiv2_version: [0.27.7]
exiv2_version: [0.28.1]
runs-on: ${{matrix.os}}
env:
PLATFORM_NAME: darwin
Expand Down Expand Up @@ -160,7 +160,7 @@ jobs:
matrix:
os: [windows-2019]
python_version: [3.6, 3.7, 3.8, 3.9, '3.10', '3.11', '3.12']
exiv2_version: [0.27.7]
exiv2_version: [0.28.1]
runs-on: ${{matrix.os}}
env:
PLATFORM_NAME: win
Expand Down
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[submodule ".github/exiv2"]
path = .github/exiv2
url = https://github.com/Exiv2/exiv2.git
branch = v0.27.7
branch = v0.28.1
2 changes: 1 addition & 1 deletion docs/Tutorial-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ __exiv2_version__ = '...'

## convert

- Exiv2 支持将某些 EXIF 或 IPTC 标签,转换成 XMP 标签,也支持反向转换。参考:<https://github.com/Exiv2/exiv2/blob/v0.27.7/src/convert.cpp#L313>
- Exiv2 支持将某些 EXIF 或 IPTC 标签,转换成 XMP 标签,也支持反向转换。参考:<https://github.com/Exiv2/exiv2/blob/v0.28.1/src/convert.cpp#L313>
- 示例:
```py
>>> pyexiv2.convert_exif_to_xmp({'Exif.Image.Artist': 'test-中文-', 'Exif.Image.Rating': '4'})
Expand Down
2 changes: 1 addition & 1 deletion docs/Tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ __exiv2_version__ = '...'

## convert

- Exiv2 supports converting some EXIF or IPTC tags to XMP tags, and also supports reverse conversion. Reference: <https://github.com/Exiv2/exiv2/blob/v0.27.7/src/convert.cpp#L313>
- Exiv2 supports converting some EXIF or IPTC tags to XMP tags, and also supports reverse conversion. Reference: <https://github.com/Exiv2/exiv2/blob/v0.28.1/src/convert.cpp#L313>
- For example:
```py
>>> pyexiv2.convert_exif_to_xmp({'Exif.Image.Artist': 'test-中文-', 'Exif.Image.Rating': '4'})
Expand Down
24 changes: 12 additions & 12 deletions pyexiv2/lib/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@

1. Download [the release of Exiv2](https://www.exiv2.org/archive.html) :
```sh
curl -O https://github.com/Exiv2/exiv2/releases/download/v0.27.7/exiv2-0.27.7-Linux64.tar.gz
tar -zxvf exiv2-0.27.7-Linux64.tar.gz
curl -O https://github.com/Exiv2/exiv2/releases/download/v0.28.1/exiv2-0.28.1-Linux64.tar.gz
tar -zxvf exiv2-0.28.1-Linux64.tar.gz
```

2. Prepare environment variables according to your download path:
```sh
EXIV2_DIR=??/exiv2-0.27.7-Linux64
EXIV2_DIR=??/exiv2-0.28.1-Linux64
LIB_DIR=??/pyexiv2/lib/
cp $EXIV2_DIR/lib/libexiv2.so.0.27.7 $EXIV2_DIR/lib/libexiv2.so
cp $EXIV2_DIR/lib/libexiv2.so.0.27.7 $LIB_DIR/libexiv2.so
cp $EXIV2_DIR/lib/libexiv2.so.0.28.1 $EXIV2_DIR/lib/libexiv2.so
cp $EXIV2_DIR/lib/libexiv2.so.0.28.1 $LIB_DIR/libexiv2.so
```

3. Prepare the python interpreter:
Expand Down Expand Up @@ -65,15 +65,15 @@

1. Download [the release of Exiv2](https://www.exiv2.org/archive.html) :
```sh
curl -O https://github.com/Exiv2/exiv2/releases/download/v0.27.7/exiv2-0.27.7-Darwin.tar.gz
tar -zxvf exiv2-0.27.7-Darwin.tar.gz
curl -O https://github.com/Exiv2/exiv2/releases/download/v0.28.1/exiv2-0.28.1-Darwin.tar.gz
tar -zxvf exiv2-0.28.1-Darwin.tar.gz
```

2. Prepare environment variables according to your download path:
```sh
EXIV2_DIR=??/exiv2-0.27.7-Darwin
EXIV2_DIR=??/exiv2-0.28.1-Darwin
LIB_DIR=??/pyexiv2/lib
cp ${EXIV2_DIR}/lib/libexiv2.0.27.7.dylib ${LIB_DIR}/libexiv2.dylib
cp ${EXIV2_DIR}/lib/libexiv2.0.28.1.dylib ${LIB_DIR}/libexiv2.dylib
```

3. Prepare the python interpreter:
Expand Down Expand Up @@ -102,16 +102,16 @@

1. Download [the release of Exiv2](https://www.exiv2.org/archive.html) :
```sh
curl -O https://github.com/Exiv2/exiv2/releases/download/v0.27.7/exiv2-0.27.7-2019msvc64.zip
python -m zipfile -e exiv2-0.27.7-2019msvc64.zip .
curl -O https://github.com/Exiv2/exiv2/releases/download/v0.28.1/exiv2-0.28.1-2019msvc64.zip
python -m zipfile -e exiv2-0.28.1-2019msvc64.zip .
```

2. Install `Visual Studio 2019` (must use the same version of Visual Studio as the Exiv2 build) , and set the environment variables it needs.

3. Prepare environment variables according to your download path:
```batch
"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat"
set EXIV2_DIR=??\exiv2-0.27.7-2019msvc64
set EXIV2_DIR=??\exiv2-0.28.1-2019msvc64
set LIB_DIR=??\pyexiv2\lib
copy %EXIV2_DIR%\bin\exiv2.dll %LIB_DIR%
```
Expand Down
26 changes: 13 additions & 13 deletions pyexiv2/lib/exiv2api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,20 +122,20 @@ class Buffer{

class Image{
public:
Exiv2::Image::AutoPtr *img = new Exiv2::Image::AutoPtr;
Exiv2::Image::UniquePtr *img = new Exiv2::Image::UniquePtr;

Image(const char *filename){
*img = Exiv2::ImageFactory::open(filename);
if (img->get() == 0)
throw Exiv2::Error(Exiv2::kerErrorMessage, "Can not open this image.");
throw Exiv2::Error(Exiv2::ErrorCode::kerErrorMessage, "Can not open this image.");
(*img)->readMetadata(); // Calling readMetadata() reads all types of metadata supported by the image
check_error_log();
}

Image(Buffer buffer){
*img = Exiv2::ImageFactory::open((Exiv2::byte *)buffer.data, buffer.size);
if (img->get() == 0)
throw Exiv2::Error(Exiv2::kerErrorMessage, "Can not open this image.");
throw Exiv2::Error(Exiv2::ErrorCode::kerErrorMessage, "Can not open this image.");
(*img)->readMetadata();
check_error_log();
}
Expand Down Expand Up @@ -214,15 +214,15 @@ class Image{

py::object read_icc()
{
Exiv2::DataBuf *buf = (*img)->iccProfile();
return py::bytes((char*)buf->pData_, buf->size_);
Exiv2::DataBuf buf = (*img)->iccProfile();
return py::bytes((char*)buf.c_str(), buf.size());
}

py::object read_thumbnail()
{
Exiv2::ExifThumb exifThumb((*img)->exifData());
Exiv2::DataBuf buf = exifThumb.copy();
return py::bytes((char*)buf.pData_, buf.size_);
return py::bytes((char*)buf.c_str(), buf.size());
}

void modify_exif(py::list table, py::str encoding)
Expand Down Expand Up @@ -283,7 +283,7 @@ class Image{
}
else if (typeName == "array")
{
Exiv2::Value::AutoPtr value = Exiv2::Value::create(Exiv2::string);
Exiv2::Value::UniquePtr value = Exiv2::Value::create(Exiv2::string);
for (auto item: line[1]){
std::string item_str = py::bytes(py::str(item).attr("encode")(encoding));
value->read(item_str);
Expand Down Expand Up @@ -317,7 +317,7 @@ class Image{
}
else if (typeName == "array")
{
Exiv2::Value::AutoPtr value = Exiv2::Value::create(Exiv2::xmpSeq);
Exiv2::Value::UniquePtr value = Exiv2::Value::create(Exiv2::xmpSeq);
for (auto item: line[1]){
std::string item_str = py::bytes(py::str(item).attr("encode")(encoding));
value->read(item_str);
Expand All @@ -335,7 +335,7 @@ class Image{
std::string data_str = py::bytes(data.attr("encode")(encoding));
(*img)->setXmpPacket(data_str);
(*img)->writeMetadata();
(*img)->writeXmpFromPacket(); // Refresh the parsed XMP data in memory
(void)(*img)->writeXmpFromPacket(); // Refresh the parsed XMP data in memory
check_error_log();
}

Expand All @@ -350,7 +350,7 @@ class Image{
void modify_icc(const char *data, long size)
{
Exiv2::DataBuf buf((Exiv2::byte *) data, size);
(*img)->setIccProfile(buf);
(*img)->setIccProfile(std::move(buf));
(*img)->writeMetadata();
check_error_log();
}
Expand Down Expand Up @@ -464,7 +464,7 @@ py::object convert_iptc_to_xmp(py::list table, py::str encoding)
}
else if (typeName == "array")
{
Exiv2::Value::AutoPtr value = Exiv2::Value::create(Exiv2::string);
Exiv2::Value::UniquePtr value = Exiv2::Value::create(Exiv2::string);
for (auto item: line[1]){
std::string item_str = py::bytes(py::str(item).attr("encode")(encoding));
value->read(item_str);
Expand Down Expand Up @@ -504,7 +504,7 @@ py::object convert_xmp_to_exif(py::list table, py::str encoding)
}
else if (typeName == "array")
{
Exiv2::Value::AutoPtr value = Exiv2::Value::create(Exiv2::xmpSeq);
Exiv2::Value::UniquePtr value = Exiv2::Value::create(Exiv2::xmpSeq);
for (auto item: line[1]){
std::string item_str = py::bytes(py::str(item).attr("encode")(encoding));
value->read(item_str);
Expand Down Expand Up @@ -544,7 +544,7 @@ py::object convert_xmp_to_iptc(py::list table, py::str encoding)
}
else if (typeName == "array")
{
Exiv2::Value::AutoPtr value = Exiv2::Value::create(Exiv2::xmpSeq);
Exiv2::Value::UniquePtr value = Exiv2::Value::create(Exiv2::xmpSeq);
for (auto item: line[1]){
std::string item_str = py::bytes(py::str(item).attr("encode")(encoding));
value->read(item_str);
Expand Down
2 changes: 1 addition & 1 deletion pyexiv2/tests/test_func.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
def test_version():
try:
from .base import __exiv2_version__
assert __exiv2_version__ == '0.27.7'
assert __exiv2_version__ == '0.28.1'
except:
ENV.skip_test = True
raise
Expand Down
Loading