image-rs / image

Encoding and decoding images in Rust
Apache License 2.0
4.78k stars 593 forks source link

SVG image "format could not be determined" #2279

Open nricciardi opened 2 weeks ago

nricciardi commented 2 weeks ago

I'm trying to open and decode SVG image, but error occurs: The image format could not be determined

let image = ImageReader::open(src_pathbuf.clone())?.decode();

I'm on Linux Mint (kernel: 5.15.0-113-generic), in toml: image = "0.24.8"

Following the SVG image which I'm using:

ipv4-packet

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->

<svg
   version="1.1"
   id="svg2"
   xml:space="preserve"
   width="935.79626"
   height="427.02063"
   viewBox="0 0 935.79627 427.02063"
   sodipodi:docname="IPv4_Packet-en.svg"
   inkscape:version="1.2.1 (9c6d41e410, 2022-07-14)"
   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
   xmlns="http://www.w3.org/2000/svg"
   xmlns:svg="http://www.w3.org/2000/svg"
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:cc="http://creativecommons.org/ns#"
   xmlns:dc="http://purl.org/dc/elements/1.1/"><metadata
     id="metadata8"><rdf:RDF><cc:Work
         rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
           rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title /></cc:Work></rdf:RDF></metadata><defs
     id="defs6"><clipPath
       clipPathUnits="userSpaceOnUse"
       id="clipPath18"><path

[.....]
fintelia commented 2 weeks ago

SVG is not one of the currently supported file formats

nricciardi commented 2 weeks ago

Is support planned?

fintelia commented 2 weeks ago

There are no current plans. Also, SVG is a vector format while all our current formats are raster, so it isn't obvious how support would even work

Shnatsel commented 1 day ago

For loading SVG in Rust see https://github.com/RazrFalcon/resvg