hzeller / timg

A terminal image and video viewer.
GNU General Public License v2.0
1.91k stars 73 forks source link

Cannot display certain SVG files #122

Closed gzagatti closed 7 months ago

gzagatti commented 9 months ago

There are some svg files that cannot be displayed by timg. The SVG file from the SVG Wiki page is one of them.

I have found this issue when using some svg compression tools like svgo and scour. It happens that I can display the svg file with timg before optimization but not after.

Any idea of what might be going on?

hzeller commented 9 months ago

I am using graphicsmagick to load SVGs. Maybe I should consider using librsvg directly for SVG files...

hzeller commented 9 months ago

Alright, confirmed that librsvg can read the file in question. Will add this to timg soon.

gzagatti commented 9 months ago

Thanks for the quick response. I had no idea about these different libraries. Glad that the solution is kind of simple.

hzeller commented 9 months ago

I've added a dedicated renderer for SVG based on the rsvg library. This should now result in much higher quality renderings of SVGs (currently works well for the high-resolution image output of timg, not yet the timg 'block-graphics' outputs).

I confirmed that it can render the test image you mentioned. The default rendering takes the size-hints coming from the image, but using the -U option of timg, it also losslessly scales it up to fit into the available space.

This will be in the next release, but if you want to try it now, compile timg from head or use the AppImage timg-v1.5.3-9-x86_64.AppImage.

hzeller commented 7 months ago

The latest release now includes this improved renderer: https://github.com/hzeller/timg/releases/tag/v1.6.0

gzagatti commented 7 months ago

Thanks so much! I have recently updated timg and it can now display svg images correctly.