Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The file information does not meet the expected requirements when I convert SVG to PNG #228

Open
ramzeng opened this issue Apr 1, 2023 · 3 comments

Comments

@ramzeng
Copy link

ramzeng commented Apr 1, 2023

ImageMagick version

6.9.11-60

Operating system

Linux

Operating system, version and so on

Debian 11

Description

convert -verbose -background none test.svg test.png
'inkscape' '/tmp/magick-5aByHNbFiOY8OJMuy3g7BEim0mQGDQnL' --export-filename='/tmp/magick-8ByznSUDzR7PWAqsLa_bLjGvPaZrzHQH.png' --export-dpi='96' --export-background='rgb(0%,0%,0%)' --export-background-opacity='-9.9999999999999997989e-13' > '/tmp/magick-8HQAAdD4GMIRUwbMkF8a3TMfHl7TAUQK' 2>&1
/tmp/magick-8ByznSUDzR7PWAqsLa_bLjGvPaZrzHQH.png PNG 36x36 36x36+0+0 8-bit sRGB 1882B 0.000u 0:00.000
41hfgwiqe9scveubfhwjfi4nuetqm59ia7busxo0l09jknt0.svg SVG 36x36 36x36+0+0 8-bit sRGB 1882B 0.000u 0:00.000
41hfgwiqe9scveubfhwjfi4nuetqm59ia7busxo0l09jknt0.svg=>2.png SVG 36x36 36x36+0+0 8-bit sRGB 2066B 0.000u 0:00.001
'inkscape' '/tmp/magick-BTvxE1PzzSvU8s-LabqLDTGXqRLISO69' --export-filename='/tmp/magick-88gyEZ4cXPS5z3088Xpm9gqIZ-TIi1oa.png' --export-dpi='96' --export-background='rgb(0%,0%,0%)' --export-background-opacity='-9.9999999999999997989e-13' > '/tmp/magick-ixZywDybGfNPuFvktw_TkGodv4Eq33ga' 2>&1
/tmp/magick-88gyEZ4cXPS5z3088Xpm9gqIZ-TIi1oa.png PNG 1x1 1x1+0+0 8-bit sRGB 126B 0.000u 0:00.000
41hfgwiqe9scveubfhwjfi4nuetqm59ia7busxo0l09jknt0.svg SVG 1x1 1x1+0+0 8-bit sRGB 126B 0.000u 0:00.000
41hfgwiqe9scveubfhwjfi4nuetqm59ia7busxo0l09jknt0.svg=>2.png SVG 1x1 1x1+0+0 8-bit sRGB 2c 317B 0.000u 0:00.000

i execute the same command on the same file will result in different outcomes.

Steps to Reproduce

echo '<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 36 36">
  <path fill="#78B159" d="M18 25.18C3.438 25.18 0 29.844 0 32s1.791 4 4 4h28c2.209 0 4-1.851 4-4s-3.438-6.82-18-6.82z"></path>
  <path fill="#662113" d="M28.804 28.15c0 1.531-1.242 2.08-2.773 2.08c-1.531 0-2.773-.548-2.773-2.08l.693-6.239c0-1.531.548-1.387 2.08-1.387c1.531 0 2.08-.145 2.08 1.387l.693 6.239z"></path>
  <path fill="#5C913B" d="M34.868 19.717c-4.59-4.135-6.449-10.056-8.837-10.056s-4.247 5.921-8.836 10.056c-1.929 1.738-1.01 2.743 1.634 2.542c2.357-.179 4.561-.741 7.202-.741s4.846.563 7.202.741c2.644.201 3.563-.805 1.635-2.542z"></path>
  <path fill="#3E721D" d="M33.377 18.078c-3.527-3.401-5.509-8.273-7.346-8.273c-1.836 0-3.818 4.872-7.345 8.273c-2.803 2.703 3.673 3.309 7.345 0c3.671 3.309 10.148 2.703 7.346 0z"></path>
  <path fill="#5C913B" d="M33.377 15.323c-3.527-3.178-5.509-7.729-7.346-7.729c-1.836 0-3.818 4.551-7.345 7.729c-2.803 2.525 3.673 3.091 7.345 0c3.671 3.091 10.148 2.524 7.346 0z"></path>
  <path fill="#3E721D" d="M31.766 13.066c-2.753-2.481-4.301-6.034-5.735-6.034c-1.433 0-2.981 3.553-5.735 6.034c-2.188 1.971 2.867 2.414 5.735 0c2.867 2.413 7.923 1.971 5.735 0z"></path> 
  <path fill="#5C913B" d="M31.766 11.001c-2.753-2.481-4.301-6.034-5.735-6.034c-1.433 0-2.981 3.553-5.735 6.034c-2.188 1.971 2.867 2.414 5.735 0c2.867 2.414 7.923 1.972 5.735 0z"></path> 
  <path fill="#3E721D" d="M30.659 9.168c-2.222-2.002-3.471-4.869-4.628-4.869s-2.406 2.867-4.628 4.869c-1.766 1.591 2.314 1.948 4.628 0c2.314 1.948 6.395 1.591 4.628 0z"></path>
  <path fill="#5C913B" d="M30.659 7.614c-2.222-2.002-3.471-4.869-4.628-4.869s-2.406 2.867-4.628 4.869c-1.766 1.591 2.314 1.948 4.628 0c2.314 1.948 6.395 1.591 4.628 0z"></path>
  <path fill="#3E721D" d="M29.553 5.326c-1.69-1.523-2.641-3.705-3.522-3.705c-.88 0-1.831 2.182-3.522 3.705c-1.344 1.211 1.761 1.482 3.522 0c1.761 1.483 4.866 1.211 3.522 0z"></path>
  <path fill="#5C913B" d="M29.553 4.29C27.863 2.767 26.912.585 26.031.585c-.88 0-1.831 2.182-3.522 3.705c-1.344 1.211 1.761 1.482 3.522 0c1.761 1.482 4.866 1.211 3.522 0z"></path>
  <path fill="#F4900C" d="M15.101 33c-.424 0-.802-.267-.944-.666L9.145 18.301a.964.964 0 0 1 .125-.896a.99.99 0 0 1 .82-.405h11.759c.401 0 .764.22.922.589l6.014 14.023A.994.994 0 0 1 27.862 33H15.101z"></path>
  <path fill="#FFCC4D" d="M4.075 33a1.005 1.005 0 0 1-.921-1.398L9.172 17.56a1.002 1.002 0 0 1 1.843 0l6.018 14.041A1.006 1.006 0 0 1 16.111 33H4.075z"></path>
  <path fill="#292F33" d="M10.09 19.436L8.084 33h4.01z"></path>
  <path fill="#FFAC33" d="M14.127 31.887L14.575 33h-2.481zm-8.075 0L5.604 33h2.48z"></path>
  <path fill="#FFE8B6" d="M12.094 33s1.823-.465 2.714-1.288L10.09 19.436L12.094 33zm-4.01 0s-1.823-.465-2.714-1.288l4.719-12.277L8.084 33z"></path>
  <path fill="#E1E8ED" d="M13.625 5.625c-.018 0-.034.006-.052.006a2.5 2.5 0 0 0-2.448-3.007a2.49 2.49 0 0 0-2.11 1.171a2.48 2.48 0 0 0-.89-.17a2.491 2.491 0 0 0-2.469 2.19a2.422 2.422 0 0 0-.906-.19a2.5 2.5 0 1 0 0 5h8.875a2.5 2.5 0 1 0 0-5z"></path>
</svg>' > test.svg

convert -verbose -background none test.svg test.png

Images

image

image

the first one is error, but the second is success.

@dlemstra dlemstra transferred this issue from ImageMagick/ImageMagick Apr 1, 2023
@dlemstra
Copy link
Member

dlemstra commented Apr 1, 2023

This is most likely an inkscape issue? But I also wonder if they can handle -9.9999999999999997989e-13 as the value for --export-background-opacity.

@ramzeng
Copy link
Author

ramzeng commented Apr 3, 2023

This is most likely an inkscape issue? But I also wonder if they can handle -9.9999999999999997989e-13 as the value for --export-background-opacity.

thanks for your answer, why not set 0 as the value for --export-background-opacity

@urban-warrior
Copy link
Member

We get an opacity for '0' for the latest releases of ImageMagick as expected. We're not sure why you instead get a really small number.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants