Using other svg delegate

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
tsdineen
Posts: 81
Joined: 2007-01-18T08:45:31-07:00

Re: Using other svg delegate

Post by tsdineen » 2016-04-26T12:40:26-07:00

Yes, I use the C api. My example for ImageMagick not working is display, broken down to rsvg(-view) failing.

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

Re: Using other svg delegate

Post by fmw42 » 2016-04-26T12:46:45-07:00

Perhaps I do not understand fully. Are you saying that it works fine if you create an output image and then view it in some other viewer, but fails if you use display to view it directly? I do not understand the rsvg-view. Sorry, I am not an expert on svg.

tsdineen
Posts: 81
Joined: 2007-01-18T08:45:31-07:00

Re: Using other svg delegate

Post by tsdineen » 2016-04-26T13:35:26-07:00

In the simplest repro, the file fails to display properly, if I use

1) display ansg011.svg
2) rsvg-view ansg011.svg
3) rsvg-convert ansg011.svg > ansg011.png
display ansg011.png

It displays properly, if I use

1) gwenview ansg011.svg
2) ksvgtopng ... ansg011.svg ansg011.png
display ansg011.png

I want to be able to change the delegate tool for svg, such that

display ansg011.svg

will use ksvgtopng, without having to pre-code the file.

tsdineen
Posts: 81
Joined: 2007-01-18T08:45:31-07:00

Re: Using other svg delegate

Post by tsdineen » 2016-04-29T09:44:47-07:00

How do you setup a delegate for a KSVG: prefix? I thought it was just as simple as adding a line in the delegates.xml like

<delegate decode="ksvg" command=""/usr/bin/ksvgtopng" "%i" "%o""/>

snibgo
Posts: 12272
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Using other svg delegate

Post by snibgo » 2016-04-29T10:08:10-07:00

<delegate decode="ksvg" command=""/usr/bin/ksvgtopng" "%i" "%o""/>

That's the general idea. Does it work? If not, what happens instead?
snibgo's IM pages: im.snibgo.com

tsdineen
Posts: 81
Joined: 2007-01-18T08:45:31-07:00

Re: Using other svg delegate

Post by tsdineen » 2016-04-29T10:43:36-07:00

rh6gold:dev/tls>/usr/bin/display KSVG:ansg011.svg
display: no decode delegate for this image format `/tmp/magick-geY7prO8' @ error/constitute.c/ReadImage/566.

Though I renamed the svg delegate to rsvg and that worked.
rh6gold:dev/tls>/usr/bin/display RSVG:ansg011.svg
<displays>

snibgo
Posts: 12272
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Using other svg delegate

Post by snibgo » 2016-04-29T11:14:42-07:00

I don't use display or ksvgtopng as neither are available on Windows, so I can't investigate. Sorry.

Does it work with convert?
snibgo's IM pages: im.snibgo.com

tsdineen
Posts: 81
Joined: 2007-01-18T08:45:31-07:00

Re: Using other svg delegate

Post by tsdineen » 2016-04-29T11:37:38-07:00

No. It gives the same error.

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

Re: Using other svg delegate

Post by fmw42 » 2016-04-29T11:44:25-07:00

This may be a dumb questions, but just checking. Did you edit the delegates.xml file in the correct directory and not just in the download folder.

On my Mac,

Code: Select all

find /usr | grep "delegates.xml"
/usr/local/etc/ImageMagick-6/delegates.xml
/usr/local/share/doc/ImageMagick-6/www/source/delegates.xml

I believe you want the one in blue. IM looks in several places for them. See http://www.imagemagick.org/script/resources.php

tsdineen
Posts: 81
Joined: 2007-01-18T08:45:31-07:00

Re: Using other svg delegate

Post by tsdineen » 2016-04-29T11:46:21-07:00

Yes, it is in /etc/ImageMagick/ and it being picked up. Verified that with strace.

tsdineen
Posts: 81
Joined: 2007-01-18T08:45:31-07:00

Re: Using other svg delegate

Post by tsdineen » 2016-05-10T14:57:09-07:00

I have the delegate working if I prefix display or convert with KSVG:. How do I translate that to the C api? I thought it was a matter of setting the ImageInfo->magick before calling ReadImage().

tsdineen
Posts: 81
Joined: 2007-01-18T08:45:31-07:00

Re: Using other svg delegate

Post by tsdineen » 2016-05-10T15:24:52-07:00

Nevermind, I figured it out. Instead of using the ImageInfo->magick, you need to set the ImageInfo->filename to include the magick prefix.

so,

strcpy( imageinfo->filename, filename );

would need to be set to

strcpy( imageinfo->filename, "KSVG:" );
strcat( imageinfo->filename, filename );

Then you can call ReadImage().

snibgo
Posts: 12272
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Using other svg delegate

Post by snibgo » 2016-05-10T15:32:58-07:00

That's how I do it.
snibgo's IM pages: im.snibgo.com

Post Reply