Skip to content

Commit

Permalink
Merge branch 'master' of github.com:ui/da-vinci
Browse files Browse the repository at this point in the history
  • Loading branch information
selwin committed Jul 11, 2023
2 parents 193e63c + f5c8ec2 commit b75fa5b
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 8 deletions.
5 changes: 5 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ To run tests::
Changelog
---------

Version 0.4.0
=============
* Support Pillow 10
* Preserve EXIF data when image is rotated

Version 0.3.0
=============
* Added webp extension support
Expand Down
2 changes: 1 addition & 1 deletion da_vinci/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
VERSION = (0, 3, 0)
VERSION = (0, 4, 0)

from .images import Image
12 changes: 9 additions & 3 deletions da_vinci/images.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import os

from PIL import Image as PILImage
from PIL import ImageEnhance
from PIL import ImageEnhance, ImageOps

from . import formats
from .compat import string_types, urlopen, urlparse
Expand Down Expand Up @@ -32,10 +32,11 @@ def __init__(self, path_or_url):
self.name = os.path.basename(path_or_url)
else:
self._pil_image = PILImage.open(path_or_url)
self.filename = self._pil_image.filename
self.filename = self._pil_image.filename if self._pil_image.filename else path_or_url.name
self.name = os.path.basename(self.filename)

self._format = self._pil_image.format
self._pil_image = ImageOps.exif_transpose(self._pil_image)
self._quality = None

@property
Expand Down Expand Up @@ -146,10 +147,15 @@ def resize(self, width=None, height=None, method='stretch'):
dimension is completely covered. Aspect ratio is preserved, parts of
the image may not be within the specified dimension.
"""
try:
resample = PILImage.ANTIALIAS
except AttributeError:
resample = PILImage.LANCZOS

self._pil_image = self._pil_image.resize(
calculate_dimensions(width, height, self.width, self.height,
method=method),
resample=PILImage.ANTIALIAS
resample=resample
)

def crop(self, width, height, center=('50%', '50%'),
Expand Down
11 changes: 7 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

setup(
name='da-vinci',
version='0.3.0',
version='0.4.0',
author='Selwin Ong',
author_email='[email protected]',
packages=['da_vinci'],
Expand All @@ -15,16 +15,19 @@
include_package_data=True,
package_data={'': ['README.rst']},
classifiers=[
'Development Status :: 3 - Alpha',
"Development Status :: 5 - Production/Stable",
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Topic :: Software Development :: Libraries :: Python Modules',
'Topic :: Multimedia :: Graphics'
]
Expand Down

0 comments on commit b75fa5b

Please sign in to comment.