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

Different output from converting SVG file provided via StringIO and filename #296

Closed
dcunhas opened this issue Jun 17, 2016 · 4 comments
Closed
Labels
upstream-issue Requires a functionality / behavior change outside of this python project

Comments

@dcunhas
Copy link

dcunhas commented Jun 17, 2016

I was doing some conversions to figure out the Wand API and I noticed that when I provide the same SVG string two different ways, I get two different images.
My code is:

from wand.image import Image
import StringIO
import os


print os.environ['MAGICK_HOME']

svg = '<?xml version="1.0" encoding="UTF-8" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" xml:space="preserve" height="241"  width="386"><g xmlns="http://www.w3.org/2000/svg" fill="none" stroke="none" stroke-width="none" stroke-linecap="butt" stroke-linejoin="miter" stroke-miterlimit="10" stroke-dasharray="" stroke-dashoffset="0" font-family="sans-serif" font-weight="normal" font-size="12" text-anchor="start" mix-blend-mode="normal"><path d="M165.2135,102.5625c0,-8.99478 7.29171,-16.2865 16.2865,-16.2865c8.99478,0 16.2865,7.29171 16.2865,16.2865c0,8.99478 -7.29171,16.2865 -16.2865,16.2865c-8.99478,0 -16.2865,-7.29171 -16.2865,-16.2865z" fill="#808080" stroke="#ffff00" stroke-width="3" opacity="0.3"/></g></svg>'

st = StringIO.StringIO(svg)
st.seek(0)

with Image(filename='C:/Users/Sandeep/temp/test.svg', format='svg') as img:
    img.format='png'
    img.save(filename="C:/Users/Sandeep/temp/s.png")

with Image(file=st, format='svg') as img:
    img.format='png'
    img.save(filename="C:/Users/Sandeep/temp/t.png")

s.png and t.png (the two output files) show different images. Furthermore, they have different file sizes (s.png is 2.54 KB and t.png is 3.12 KB). I verified that the file contents are the same as the contents of the string above, so what's going on?

@emcconville
Copy link
Owner

emcconville commented Jun 17, 2016

Might have better luck at the ImageMagick community form. This is more of an IM issue than a Wand.

Also, Which version of IM & Wand are you using? I'm using Wand 0.4.3 & IM 6.9.3 with the sample code provided, and the resulting output of s.png & t.png match.

@dcunhas
Copy link
Author

dcunhas commented Jun 17, 2016

Thanks, I reposted this there.
I'm using Wand 0.4.3 and IM 6.9.4-Q16. Also, I'm on Windows in case that matters for some reason.

@emcconville
Copy link
Owner

Could you try the following commands?

convert test.svg s.png
cat test.svg | convert svg:-  t.png

I can't remember the windows version of the above :(

@pholica
Copy link

pholica commented Nov 27, 2016

I probably hit the same issue I used the same image from description. The result is:

$ convert test.svg s.png
$ cat test.svg | convert svg:-  t.png
$ file s.png t.png
s.png: PNG image data, 362 x 226, 8-bit colormap, non-interlaced
t.png: PNG image data, 386 x 241, 8-bit colormap, non-interlaced

I have Fedora 25 x86_64 with ImageMagick and python3-wand versions:

ImageMagick-6.9.3.0-3.fc25.x86_64
python3-wand-0.4.4-1.fc25.noarch

I'm quite sure that this wasn't issue on Fedora 24, so I may try to find where was the change. But yes, it seems to be problem of Imagemagick.

@emcconville emcconville added the upstream-issue Requires a functionality / behavior change outside of this python project label Dec 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
upstream-issue Requires a functionality / behavior change outside of this python project
Projects
None yet
Development

No branches or pull requests

3 participants