• 
      

    Fix exception of Pillow for SVGs

    Review Request #10851 — Created Jan. 24, 2020 and submitted — Latest diff uploaded

    Information

    Djblets
    release-1.0.x
    a93b0d8...

    Reviewers

    If someone uploads a SVG as file attachment
    Review Boards tries to generate a thumbnail.
    
    Pillow do not support SVGs and throws an exception.
    
    https://github.com/python-pillow/Pillow/issues/3509
    
     - djblets.util.templatetags.djblets_images - Error thumbnailing image file uploaded/files/2020/01/24/d6a12e49-05b7-42d9-bd6c-50985fd98f8e__check.svg and saving as uploaded/files/2020/01/24/d6a12e49-05b7-42d9-bd6c-50985fd98f8e__check_600.svg: cannot identify image file <cStringIO.StringI object at 0x7ff6a9b57b58>
    Traceback (most recent call last):
      File "/opt/reviewboard/dist/lib/python2.7/site-packages/djblets/util/templatetags/djblets_images.py", line 126, in thumbnail
        image = Image.open(data)
      File "/opt/reviewboard/dist/lib/python2.7/site-packages/PIL/Image.py", line 2705, in open
        % (filename if filename else fp))
    IOError: cannot identify image file <cStringIO.StringI object at 0x7ff6a9b57b58>
    
    As SVG do not need thumbnail because Browsers can
    scale that without a problem we can provide
    the original file here.

    Added an SVG file and saw that the thumbnail exists
    instead of an error 404.