Embedded images in SVG are colour inverted when converted to PNG

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
hairykid
Posts: 17
Joined: 2019-03-12T08:30:40-07:00
Authentication code: 1152

Embedded images in SVG are colour inverted when converted to PNG

Post by hairykid »

OS: Ubuntu 18.10
Version: ImageMagick 7.0.8-45

The command being run is -

convert +antialias msvg:/var/www/mydomain.co.uk/sites/default/files/tmp/preview-1359776017-m0PrE8 png:/var/www/mydomain.co.uk/sites/default/files/tmp/preview-1033156707-Hxugpl

To replicate issue -

The svg image used is here - https://ufile.io/5fk9e1e6

The converted png is here - https://ufile.io/gfwcio9g
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Embedded images in SVG are colour inverted when converted to PNG

Post by fmw42 »

Imagemagick will use any one of 3 SVG renderers: MSVG, RSVG and Inkscape. MSVG is not as good as the other and Inkscape is the best.

In IM 7, use magick not convert.

I do not see your SVG file listed in your command?

But if I use MSVG in IM 7.0.8.45 Q16 Mac OSX as:

Code: Select all

magick MSVG:original.svg orig_msvg.png
I reproduce your image. But using Inkscape with Imagemagick, I get a different result, which seems to be missing the imbedded JPG image in the SVG file.

Code: Select all

magick original.svg orig.png
Image

The preview in my Mac OSX does look inverted showing cyan-like colors. But I suspect it is an issue with the preview, not the image.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Embedded images in SVG are colour inverted when converted to PNG

Post by fmw42 »

You have an imbedded CMYK JPG in the SVG file (Logo 1_1.jpg). So that might be showing with inverted colors in an SVG file.
hairykid
Posts: 17
Joined: 2019-03-12T08:30:40-07:00
Authentication code: 1152

Re: Embedded images in SVG are colour inverted when converted to PNG

Post by hairykid »

Hi, we have tested with CMYK and it works fine. My collegue seems to now think it is the filesize of the image since the same image made smaller works fine.

This is a pretty old website and hence changing everything from MSVG may not be cost-effective. I could try inkscape I suppose, I did install this before but ImageMagick didn't seem to use it.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Embedded images in SVG are colour inverted when converted to PNG

Post by fmw42 »

Inkscape will only be used if your IM version is 6.7.9-0 or higher.
hairykid
Posts: 17
Joined: 2019-03-12T08:30:40-07:00
Authentication code: 1152

Re: Embedded images in SVG are colour inverted when converted to PNG

Post by hairykid »

I have tried installing inkscape but the issue persists unfortunately.

Here are 2 copied of the same logo, one is larger in filesize than the other, as far as I can tell that is the only difference.

https://ufile.io/cg6dwtff - This one inverts in colour (838KB)
https://ufile.io/prozc91z - This one works fine (253KB)
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Embedded images in SVG are colour inverted when converted to PNG

Post by fmw42 »

Please provide your SVG files and your exact command lines and IM version and platform. Also what do you get from

Code: Select all

convert -list format
for the line starting with SVG
hairykid
Posts: 17
Joined: 2019-03-12T08:30:40-07:00
Authentication code: 1152

Re: Embedded images in SVG are colour inverted when converted to PNG

Post by hairykid »

OS: Ubuntu 18.10
Version: ImageMagick 7.0.8-45

convert -list format outputs -
SVG rw+ Scalable Vector Graphics (XML 2.9.4)

Command being run - convert msvg:/var/www/mydomain.co.uk/sites/default/files/tmp/preview-402545132-zzD8AN png:/var/www/mydomain.co.uk/sites/default/files/preview/177390993-1558689408.png

177390993-1558689408 - https://ufile.io/896dbra2
preview-402545132-zzD8AN - https://ufile.io/r57mvuwt

Thanks
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Embedded images in SVG are colour inverted when converted to PNG

Post by fmw42 »

convert msvg:...
This is forcing the using of the internal MSVG/XML renderer. If you want to use inkscape and it is on your system and your IM version is current enough, then remove the msvg: from in front of your SVG file specification.

When I run it using Inkscape with ImageMagick, I get a "linked image is not found" graphic in the output png along with the 100.

Code: Select all

convert preview-402545132-zzd8an.svg preview-402545132-zzd8an.png
with msvg, nothing shows but the 100.

Code: Select all

convert msvg:preview-402545132-zzd8an.svg preview-402545132-zzd8an.png
Same with rsvg, nothing shows but the 100.

I do not know if any of these tools can access https: links to images imbedded in SVG files. I am not an expert on SVG. Perhaps one of the other IM users can comment further.
hairykid
Posts: 17
Joined: 2019-03-12T08:30:40-07:00
Authentication code: 1152

Re: Embedded images in SVG are colour inverted when converted to PNG

Post by hairykid »

Ok so are we saying that Inkscape doesn't even allow this type of conversion to take place?
Post Reply