Closed jrief closed 3 years ago
Are there any news about this PR?
easy-thumbnails already supports SVG images. Please try using this version: https://pypi.org/project/easy-thumbnails/2.8rc0/
If you use django-filer there is a release which uses these new features: https://pypi.org/project/django-filer/2.1rc3/
I never got any feedback on this new feature, therefore I forgot to create a production release of the above packages.
Ok, we will test it when we have time and give you feedback so that you can have production package.
Ok, I manage to integrate some things but failed on others
THUMBNAIL_PRESERVE_EXTENSIONS
Hello. I understand correctly that now it is not possible to load svg or bitmap in ThumbnailerImageField. Only raster is supported.
Or I didn’t understand something. I'm watching version 2.8rc0
Perhaps a different workflow is expected?
@jrief can you please tell how to test this rc and accept svg files through ThumbnailerImageField? installing easy-thumbnails==2.8rc0 and putting a ThumbnailerImageField on a model doesn't let me accept svg files and the admin rises an error telling me that isn't a supported image type. thanks (as a side note probably the workflow could be to use ThumbnailerField directly)
@jrief have you considered releasing VIL as a standalone package and then adding it as a dependency to easy-thumbnails? It seems like a more generally useful project that shouldn't be hidden inside a submodule of easy_thumbnails.
This PR also contains a number of unrelated changes, which makes it harder to review. Is this because you decided to use this branch as a base for the pre-release? I believe it's bad form to pre-release an unmerged (and unreviewed) branch, I would have expected at least some involvement of the original project owner (@SmileyChris).
have you considered releasing VIL as a standalone package and then adding it as a dependency to easy-thumbnails?
Actually no. Reason is, that "VIL" just mimics the behaviour of PIL without transforming the images SVG themselves. Well sort of, by changing the the coordinates inside the SVG viewbox, one can "crop" an SVG image. But I don't see any usage of that mimicking behaviour outside easy-thumbnails.
This PR also contains a number of unrelated changes, which makes it harder to review.
A requirement of the organization I am working for was to support SVG images by django-filer. With the changes in this PR, I came up with a working solution. Therefore I needed a pre-release. I asked a few people to review django-filer together with this version of easy-thumbnails, but got little feedback.
I heavily welcome you to review the changes I have made, so that I can release SVG support officially. The best way of doing this is via https://pypi.org/project/django-filer/2.1rc3/
Apparently one has to release an official version, before people start yelling, that you broke something which used to work for them.
Add support for thumbnailing SVG images.
Of course it doesn't make sense to thumbnail SVG images, because being in vector format they can scale to any size without any quality of loss. However, users of easy-thumbnails may want to upload and use SVG images just as if they would be PNG, GIF or JPEG. They don't necessarily care about the format and definitely don't want to convert them to a pixel based format. What they want is to reuse their templates with the templatetag
thumbnail
and scale and crop the images to whatever their<img src="..." width="..." height="...">
has been prepared for.This is done by adding an emulation layer named VIL, which aims to be compatible with PIL. All thumbnailing operations, such as scaling and cropping behave like pixel based images. The final filesize of such thumbnailed SVG images doesn't of course change, but their width/height and bounding box may be adjusted to reflect the desired size of the thumbnailed image.