Comments (2)
Since I have no access to S3, I can't test this. Would you be so kind and share the patch of your colleague as a PR.
from easy-thumbnails.
Sure,
Here is a patch we applied and it works for us:
def database_get_image_dimensions(file, close=False, dimensions=None): # noqa: VNE002
"""
Change svg file dimensions, because - https://github.com/SmileyChris/easy-thumbnails/issues/619
"""
storage_hash = utils.get_storage_hash(file.storage)
dimensions = None
dimensions_cache = None
try:
thumbnail = models.Thumbnail.objects.select_related('dimensions').get(storage_hash=storage_hash, name=file.name)
except models.Thumbnail.DoesNotExist:
thumbnail = None
else:
try:
dimensions_cache = thumbnail.dimensions
except models.ThumbnailDimensions.DoesNotExist:
dimensions_cache = None
if dimensions_cache:
return dimensions_cache.width, dimensions_cache.height
if os.path.splitext(file.file.name)[1] == '.svg':
from easy_thumbnails.VIL.Image import load
dimensions = load(file.file).size
else:
dimensions = get_image_dimensions(file, close=close)
if settings.THUMBNAIL_CACHE_DIMENSIONS and thumbnail:
models.ThumbnailDimensions.objects.get_or_create(
thumbnail=thumbnail, defaults={'width': dimensions[0], 'height': dimensions[1]}
)
return dimensions
easy_thumbnails_files.database_get_image_dimensions = database_get_image_dimensions
from easy-thumbnails.
Related Issues (20)
- 2.8 release breaks on M1 / python 3.9 - symbol not found in flat namespace '_FT_Done_Face' HOT 3
- django-filer 2.1.2, easy-thumbnails 2.8.1 and AWS HOT 3
- No version compatible with django 4.0 och PYPI HOT 11
- Reportlab dependency causes security warning HOT 9
- Cant install easy-thumbnails with Poetry and Django 4 HOT 4
- Template fails to render due to ZeroDivisionError when input is corrupted
- ContentFile without a name breaks easy_thumbnails
- ANTIALIAS is deprecated and will be removed in Pillow 10
- svglib dependency is missing HOT 9
- Imoprt error
- Django 4.1 template tag 'thumbnail' conflict with sorl-thumbnails
- Saving TIFF image raises Value error HOT 2
- How to force a single field to convert the thumbails to JPG even if PNG with alpha was provided
- DeprecationWarning from get_storage_class HOT 1
- Lots of duplicated queries HOT 1
- Support for pillow >= 10.0.0.0 HOT 1
- ZeroDivisionError when thumbnail is passed a 0x0 SVG HOT 1
- Increase File name field length HOT 1
- Allow use of new Django4.2 STORAGE config
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from easy-thumbnails.