ImageMagick for SVG and other image types?

John Gaffney <jgaffney-W1WbbPd4oPN/W2okNb46yti2O/[email protected]>
Newsgroups gmane.comp.web.dillo.devel
Message-ID <[email protected]>
At this point Dillo supports the display of GIF, PNG, and JPG, but SVG
is used heavily by sites like, for example, Wikipedia.  Has the
Magick++ library in ImageMagick been considered for supporting these
other image formats?  The FLTK people seem enthusiastic about the
Imago library in spite of its alpha state of development; librsvg,
which looks, at least to my untutored eye, like it requires a fair
amount of voodoo to use, is apparently no longer actively supported
and would at any rate only provide SVG support; but ImageMagick is
pretty standard with Linux distributions, and the Magick++ interface
makes conversions from any format to PNG for the purposes of display
extremely easy.  In src/misc.c, at the end of the image part of the
else-if ladder in a_Misc_get_content_type_from_data(), one could add
another "rung" that uses Data and Size to create a Magick::Blob, and
from this a Magick::Image, then use Magick::Image.write() to write
this to another Magick::Blob of type PNG, and then replace Data and
Size with those of the resulting Magick::Blob.  A try-catch block
would catch the cases where Data is not an image.  Altogether this
sort of "cheat" would require very few lines of code to implement.
And the Magick++-config utility could supply the needed -D..., -I...,
-l... flags to the configure script.

I'm not suggesting this is an ideal long-term solution, but in the
interim would at least allow the display of other image types.

The most recent mention of this on the mailing list seems to be
Jorge's indication on 22 April 2016 that

    No, there's no SVG image support in dillo yet.

    It should not be hard to implement though, but it needs an effort
    similar to GIF or PNG or JPEG code. Patch welcomed! ;)

But surely someone has thought of ImageMagick before.  Are there
objections to using it?  And if so, maybe a flag could be set by the
configure script to conditionally compile this in for those who want
it?  (If this is pursued, the configure script should probably also
check that the version of ImageMagick is recent enough to have been
patched against that serious exploit in just this sort of conversion
code.)

A test program shows that the invocation of ImageMagick and
conversions really are as simple as the steps outlined above.  But I
would be happy to make an attempt at a patch, if you don't mind this
being undertaken by an amateur.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.