Re: SVG to PNG

Bob Friesenhahn <[email protected]> Thu, 12 Nov 2020 08:18:26 -0600 (CST)
Newsgroups gmane.comp.video.graphicsmagick.help
Message-ID <[email protected]>
On Thu, 12 Nov 2020, Pro Turm wrote:

> Thanks. Two questions more:
> 1) Are there any specific APIs concerning SVG? I couldnt grub any specific
> documentation page concerning svg.

There are no specific APIs.  SVG is just an input file format.

> 2) What is the way to reject the dangerous parts of the svgs or they are
> just ignored by GM ?

Attempts to read local files are already rejected.  The FTP and HTTP 
support is marked at an "UNSTABLE" level of coder stability so setting 
the environment variable MAGICK_CODER_STABILITY to STABLE will block 
this support.

If you are writing a C/C++ program which uses the GraphicsMagick 
library, then it is good to know that the header file 
magick/confirm_access.h provides a way for the program to register a 
callback function which will be called to allow the program to "bless" 
or "reject" each file, URL, or program execution access.  This 
provides total control and is also a useful way to observe what is 
going on.  The relevent API definitions are:

   typedef enum
     {
       UndefinedConfirmAccessMode,
       FileExecuteConfirmAccessMode, /* Path is to be opened for execution */
       FileReadConfirmAccessMode,    /* Path is to be opened for read */
       FileWriteConfirmAccessMode,   /* Path is to be opened for write */
       URLGetFTPConfirmAccessMode,   /* ftp:// URL get */
       URLGetFileConfirmAccessMode,  /* file:// URL get */
       URLGetHTTPConfirmAccessMode   /* http:// URL get */
     } ConfirmAccessMode;

   typedef MagickPassFail
   (*ConfirmAccessHandler)(const ConfirmAccessMode mode,
                           const char *path,
                           ExceptionInfo *exception);

   extern MagickExport ConfirmAccessHandler
   MagickSetConfirmAccessHandler(ConfirmAccessHandler handler);

In addition to the above, resource limits may be set to limit resource 
consumption such as the size of a generated image, or the amount of 
allocated memory.

Bob
-- 
Bob Friesenhahn
[email protected], http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer,    http://www.GraphicsMagick.org/
Public Key,     http://www.simplesystems.org/users/bfriesen/public-key.txt