Merge pull request #918 from taigaio/svg-thumbnail-generation
Add svg thumbnail generationremotes/origin/github-import
commit
8bb20c2767
|
@ -8,11 +8,12 @@
|
||||||
- Ability to create rich text custom fields in Epics, User Stories, Tasks and Isues.
|
- Ability to create rich text custom fields in Epics, User Stories, Tasks and Isues.
|
||||||
- Full text search now use simple as tokenizer so search with non-english text are allowed.
|
- Full text search now use simple as tokenizer so search with non-english text are allowed.
|
||||||
- Duplicate project: allows creating a new project based on the structure of another (status, tags, colors, default values...)
|
- Duplicate project: allows creating a new project based on the structure of another (status, tags, colors, default values...)
|
||||||
|
- Add thumbnails for PSD files.
|
||||||
|
- Add thumbnails for SVG files (Cario lib is needed).
|
||||||
- i18n:
|
- i18n:
|
||||||
- Add japanese (ja) translation.
|
- Add japanese (ja) translation.
|
||||||
- Add korean (ko) translation.
|
- Add korean (ko) translation.
|
||||||
- Add chinese simplified (zh-Hans) translation.
|
- Add chinese simplified (zh-Hans) translation.
|
||||||
- Add thumbnails for PSD files.
|
|
||||||
|
|
||||||
### Misc
|
### Misc
|
||||||
- API:
|
- API:
|
||||||
|
|
|
@ -34,3 +34,4 @@ python-dateutil==2.6.0
|
||||||
netaddr==0.7.18
|
netaddr==0.7.18
|
||||||
serpy==0.1.1
|
serpy==0.1.1
|
||||||
psd-tools==1.4
|
psd-tools==1.4
|
||||||
|
CairoSVG==2.0.1
|
||||||
|
|
|
@ -26,12 +26,28 @@ from taiga.base.utils.urls import get_absolute_url
|
||||||
from easy_thumbnails.files import get_thumbnailer
|
from easy_thumbnails.files import get_thumbnailer
|
||||||
from easy_thumbnails.exceptions import InvalidImageFormatError
|
from easy_thumbnails.exceptions import InvalidImageFormatError
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
from PIL.PngImagePlugin import PngImageFile
|
||||||
|
|
||||||
|
from io import BytesIO
|
||||||
|
|
||||||
|
# SVG thumbnail generator
|
||||||
|
try:
|
||||||
|
from cairosvg.surface import PNGSurface
|
||||||
|
|
||||||
|
def svg_image_factory(data, *args):
|
||||||
|
png_data = PNGSurface.convert(data.read())
|
||||||
|
return PngImageFile(BytesIO(png_data))
|
||||||
|
|
||||||
|
Image.register_mime("SVG", "image/svg+xml")
|
||||||
|
Image.register_extension("SVG", ".svg")
|
||||||
|
Image.register_open("SVG", svg_image_factory)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
|
# PSD thumbnail generator
|
||||||
def psd_image_factory(data, *args):
|
def psd_image_factory(data, *args):
|
||||||
return PSDImage.from_stream(data).as_PIL()
|
return PSDImage.from_stream(data).as_PIL()
|
||||||
|
|
||||||
|
|
||||||
Image.init()
|
Image.init()
|
||||||
Image.register_open("PSD", psd_image_factory)
|
Image.register_open("PSD", psd_image_factory)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue