Try to use modern rsvg functions when we can
This commit is contained in:
parent
35092562e6
commit
12582ba2f5
@ -30,12 +30,23 @@ class SVGParser(exiftool.ExiftoolParser):
|
|||||||
svg = Rsvg.Handle.new_from_file(self.filename)
|
svg = Rsvg.Handle.new_from_file(self.filename)
|
||||||
except GLib.GError:
|
except GLib.GError:
|
||||||
raise ValueError
|
raise ValueError
|
||||||
|
|
||||||
|
try:
|
||||||
|
_, _, _, _, has_viewbox, viewbox = svg.get_intrinsic_dimensions()
|
||||||
|
if has_viewbox is False:
|
||||||
|
raise ValueError
|
||||||
|
_, width, height = svg.get_intrinsic_size_in_pixels()
|
||||||
|
except AttributeError:
|
||||||
dimensions = svg.get_dimensions()
|
dimensions = svg.get_dimensions()
|
||||||
surface = cairo.SVGSurface(self.output_filename,
|
height, width = dimensions.height, dimensions.width
|
||||||
dimensions.height,
|
|
||||||
dimensions.width)
|
surface = cairo.SVGSurface(self.output_filename, height, width)
|
||||||
context = cairo.Context(surface)
|
context = cairo.Context(surface)
|
||||||
|
try:
|
||||||
|
svg.render_document(context, viewbox)
|
||||||
|
except AttributeError:
|
||||||
svg.render_cairo(context)
|
svg.render_cairo(context)
|
||||||
|
|
||||||
surface.finish()
|
surface.finish()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user