Hello,
I would convert a SVG file to a PNG file with Imagick PHP. I use the command line and the generated image file is ok except for the patterns images : the repeat seems to not be exact and we can see 1 or 2 pixels space beetwen repeat bloc image.
On Chrome browser the SVG render is perfect. And I have tested with RSVG and Inkscape: same problem...
Here you can find some pictures to illustrate : (please open it in full size to view the issue)
Expected render in Chrome :
Imagick render :
Inkscape (look at the star the 1 pixel black lines) :
RSVG (repeat position is right but not the last text border and the image shadow blur) :
Is it a bug ? An error in my SVG syntax ?
Thanks for your help
Clement
Configuration :
PHP Version 7.1.27-1+0~20190307202204.14+stretch~1.gbp7163d5
imagick module version 3.4.3
imagick classes Imagick, ImagickDraw, ImagickPixel, ImagickPixelIterator, ImagickKernel
Imagick compiled with ImageMagick version ImageMagick 6.9.7-4 Q16 x86_64 20170114
SVG to PNG pattern image repeat issue
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: SVG to PNG pattern image repeat issue
You haven't shown your SVG.Csi wrote:Is it a bug ? An error in my SVG syntax ?
The SVG standard doesn't mandate exact outputs, so two SVG renderers that both comply with the standard can make different outputs. SVG code written to look "correct" with one renderer can look "wrong" on another.
snibgo's IM pages: im.snibgo.com
Re: SVG to PNG pattern image repeat issue
@snibgo thanks for your reply
Sorry, you can find the original svg here : https://www.prima-cms.com/2629.svg
(Doesn't matter with the light wide order around the picture, I delete it in my code juste before run the convert)
I have already try to change the pattern values (without any knowledge) to find if the render behavior were affected, without success.
Thanks
Sorry, you can find the original svg here : https://www.prima-cms.com/2629.svg
(Doesn't matter with the light wide order around the picture, I delete it in my code juste before run the convert)
I have already try to change the pattern values (without any knowledge) to find if the render behavior were affected, without success.
Thanks
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: SVG to PNG pattern image repeat issue
In the SVG, the height is 1500.6242197253434 pixels. Renderers will round this to 1501 pixels, creating a gap of about 0.38 pixels somewhere. Similarly, there are many other floating-point numbers, and these will cause differences due to varying precision and algorithms.
For example, the gold.jpg pattern can be simplified if you create a larger raster image and use that, so it doesn't need to be repeated.
Then replace the SVG lines with:
For example, the gold.jpg pattern can be simplified if you create a larger raster image and use that, so it doesn't need to be repeated.
Code: Select all
magick gold.jpg +clone +append +clone -append +repage g2x2.jpg
Code: Select all
<pattern id="SVGID_14" x="0" y="0" width="1" height="1">
<image x="0" y="0" width="320" height="320" xlink:href="g2x2.jpg"></image>
</pattern>
snibgo's IM pages: im.snibgo.com
Re: SVG to PNG pattern image repeat issue
@snibgo thanks for your replay
Good idea, I will search in this way. I can easily modify the svg render and I will change all float pixel number to round.
I will repost here the result.
Good idea, I will search in this way. I can easily modify the svg render and I will change all float pixel number to round.
I will repost here the result.