take shortcut in get_png if this is an empty tile rendering
This commit is contained in:
parent
6592c344b2
commit
cd09cbab68
2 changed files with 10 additions and 0 deletions
|
@ -1,4 +1,5 @@
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|
||||||
from c3nav.celery import app
|
from c3nav.celery import app
|
||||||
|
|
|
@ -85,8 +85,17 @@ class SVGImage:
|
||||||
result += '</svg>'
|
result += '</svg>'
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
empty_tile = (b'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x01\x00\x00\x00\x01\x00\x01\x03\x00\x00\x00f\xbc:%\x00'
|
||||||
|
b'\x00\x00\x03PLTE\x00\x00\x00\xa7z=\xda\x00\x00\x00\x01tRNS\x00@\xe6\xd8f\x00\x00\x00\x1fIDATh\xde'
|
||||||
|
b'\xed\xc1\x01\r\x00\x00\x00\xc2\xa0\xf7Om\x0e7\xa0\x00\x00\x00\x00\x00\x00\x00\x00\xbe\r!\x00\x00'
|
||||||
|
b'\x01\x7f\x19\x9c\xa7\x00\x00\x00\x00IEND\xaeB`\x82')
|
||||||
|
|
||||||
def get_png(self, f=None):
|
def get_png(self, f=None):
|
||||||
# render the image to png. returns bytes if f is None, otherwise it calls f.write()
|
# render the image to png. returns bytes if f is None, otherwise it calls f.write()
|
||||||
|
|
||||||
|
if self.get_dimensions_px(buffer=False) == (256, 256) and not self.g:
|
||||||
|
return self.empty_tile
|
||||||
|
|
||||||
if settings.SVG_RENDERER == 'rsvg':
|
if settings.SVG_RENDERER == 'rsvg':
|
||||||
# create buffered surfaces
|
# create buffered surfaces
|
||||||
buffered_surface = cairocffi.SVGSurface(None, *(int(i) for i in self.get_dimensions_px(buffer=True)))
|
buffered_surface = cairocffi.SVGSurface(None, *(int(i) for i in self.get_dimensions_px(buffer=True)))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue