Skip to content

Commit

Permalink
[api] add get_pixel_width() and get_pixel_height()
Browse files Browse the repository at this point in the history
  • Loading branch information
LeoHsiao1 committed Oct 5, 2024
1 parent 7422b5a commit 5845caa
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pyexiv2/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ def closed_warning(*args, **kwargs):
else:
setattr(self, attr, None)

def get_pixel_width(self) -> int:
return self._exiv2api_image.get_pixel_width()

def get_pixel_height(self) -> int:
return self._exiv2api_image.get_pixel_height()

def get_mime_type(self) -> str:
""" Get the MIME type of the image, such as 'image/jpeg'. """
return self._exiv2api_image.get_mime_type()
Expand Down
12 changes: 12 additions & 0 deletions pyexiv2/lib/exiv2api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,16 @@ class Image{
return py::bytes((char *)io.mmap(), io.size());
}

py::int_ get_pixel_width()
{
return img->pixelWidth();
}

py::int_ get_pixel_height()
{
return img->pixelHeight();
}

std::string get_mime_type()
{
return img->mimeType();
Expand Down Expand Up @@ -683,6 +693,8 @@ PYBIND11_MODULE(exiv2api, m)
.def(py::init<Buffer &>())
.def("close_image" , &Image::close_image)
.def("get_bytes" , &Image::get_bytes)
.def("get_pixel_width" , &Image::get_pixel_width)
.def("get_pixel_height" , &Image::get_pixel_height)
.def("get_mime_type" , &Image::get_mime_type)
.def("get_access_mode" , &Image::get_access_mode)
.def("read_exif" , &Image::read_exif)
Expand Down

0 comments on commit 5845caa

Please sign in to comment.