Page 1 of 3

Embedded images in SVG are colour inverted when converted to PNG

Posted: 2019-05-17T02:14:28-07:00
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

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

Posted: 2019-05-17T09:13:29-07:00
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.

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

Posted: 2019-05-17T09:25:40-07:00
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.

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

Posted: 2019-05-20T01:47:47-07:00
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.

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

Posted: 2019-05-20T09:17:45-07:00
by fmw42
Inkscape will only be used if your IM version is 6.7.9-0 or higher.

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

Posted: 2019-05-21T04:08:54-07:00
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)

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

Posted: 2019-05-21T09:13:59-07:00
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

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

Posted: 2019-05-24T02:20:46-07:00
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

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

Posted: 2019-05-24T08:04:20-07:00
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.

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

Posted: 2019-05-28T23:41:01-07:00
by hairykid
Ok so are we saying that Inkscape doesn't even allow this type of conversion to take place?

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

Posted: 2019-12-12T01:55:30-07:00
by hairykid
Hi, could I please bounce this post to the top..

My client is reporting that this issue only occurs when using CMYK images, RGB images do not get inverted. Is there any way to help make progress on this issue? I can share a working link to observer this behavior if need be.

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

Posted: 2019-12-12T08:50:35-07:00
by snibgo
Trying to download your input SVG from https://uploadfiles.io/r57mvuwt I get:
The hosting period for this file has now expired, only premium users can download it.

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

Posted: 2020-01-08T12:19:29-07:00
by hairykid
I sorry for the delay on this, I haven't been well. I am providing a zip file here - https://easyupload.io/qeddt8
Which contains 3 files

cmyk-image.jpg - this is linked to from the SVG image that we are converting and is a CMYK image
tobeconverted - this is the svg image
converted.png - the converted image

To convert this I ran the following with my folder on my desktop - convert msvg:~/Desktop/svg\ convert\ test/tobeconverted png:~/Desktop/svg\ convert\ test/converted.png

As you can see the image is inverted in the png.

I have tested with both Version: ImageMagick 7.0.9-10 and ImageMagick 6.9.7-4 and the same outcome

If it shines any light on things I can confirm that this doesn't happen with smaller CMYK images, although I can't confirm where the cut off point is in terms of filesize

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

Posted: 2020-01-08T12:28:18-07:00
by hairykid
I can confirm this works without the msvg: prefix in the convert command. I'm not sure however the contingencies involved with changing this in the application which I am working on and which I didn't develop, the ideal solution seems to be to get this to work with the msvg prefix but I will do some testing. Thanks to fmw42 for pointing this out, I should have listened at the time!

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

Posted: 2020-01-08T12:36:07-07:00
by hairykid
Ok I've done some testing, this was working locally where I have ImageMagick 7.0.9-10 installed, however on my server where we are using version 6.9.7-4 we are seeing this error with the command -

convert +antialias /var/www/website/sites/default/files/tmp/preview-547830085-NHHgtJ png:/var/www/website/sites/default/files/tmp/preview-2143991790-yUNO7c

ImageMagick error 1: convert-im6.q16: no decode delegate for this image format `' @ error/constitute.c/ReadImage/504. convert-im6.q16: no images defined

Will try to use version 7 on my server and report back.