1

I am Working on a small Image comparing script where the reference images are generated as SVGs and the compare images are PNGs. I can transform the SVG files to PNG (using svglib and renderpm) but can´t specify the size I want them to be generated as(renderscale seems to cut of a part of the picture), but I need to get them to the same size for the compare functions and resizing the pngs nullifyes the whole purpose of vector graphics in itself. Any Ideas?

Regards a python noob

twol
  • 11
  • 4
  • Did you try `cairosvg` https://stackoverflow.com/a/46135174/18667225 ? – Markus Aug 31 '22 at 07:53
  • @Markus i have tried cairosvg, but I cant manage to get it working. it alswaysthows exceptions for "missing librarys" https://prnt.sc/ZmNdtpohRGFw – twol Aug 31 '22 at 08:31
  • Did you check https://stackoverflow.com/a/60935922/18667225 ? – Markus Aug 31 '22 at 12:26
  • Thanks. That worked. The Problem I am having now is that the output png is rendered in different colors (the white imge Background is converted to gray) which is counterproductive as I am working with error measuring. Edit: background_color="white" solves ist. – twol Sep 01 '22 at 07:15
  • Update question: https://stackoverflow.com/questions/73607300/cairosvg-renders-pngs-wierdly-in-python – twol Sep 05 '22 at 10:08
  • I got `svglib` to work with `pymupdf` [on my answer to this question](https://stackoverflow.com/a/74164750/1506569) where the output size can be influenced by the `dpi` parameter. And it doesn't require any external libs, in case someone stumbles across this post as I did. – M4a1x Oct 22 '22 at 15:22

0 Answers0