diff --git a/pyexiv2/core.py b/pyexiv2/core.py index e842e99..d014acc 100644 --- a/pyexiv2/core.py +++ b/pyexiv2/core.py @@ -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() diff --git a/pyexiv2/lib/exiv2api.cpp b/pyexiv2/lib/exiv2api.cpp index 1e3cbd7..ba91274 100644 --- a/pyexiv2/lib/exiv2api.cpp +++ b/pyexiv2/lib/exiv2api.cpp @@ -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(); @@ -683,6 +693,8 @@ PYBIND11_MODULE(exiv2api, m) .def(py::init()) .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)