Drupal supports only three image formats, and while this is potentially extensible it seems like you'd have to override a lot of image.inc. In particular Drupal has no support (as far as I can tell...) for SVG image files; you can create and display SVG via the drawing module on 5.x but if you just want to treat an SVG file like an image, forget it.

Ideally, it would be possible to extend drupal to support any number of image formats. But I'm not really all that clear on how it would be logical to do that in a drupal context. I would be temporarily content :) with just SVG support, which I would be happy to help with (But probably the wrong guy...)

Obviously, I can implement SVG myself in any number of ways, it's not that difficult - but I'd prefer if everything fit into the same system.

Comments

jivmuk’s picture

You mention about the number of ways one can implement SVG. Do you have some references. I am trying since long to figure out a way to dynamically create some flow charts, still yet to figure out one good solution.

mdupont’s picture

Version: 7.x-dev » 8.x-dev

After a quick search about native SVG support in PHP:

  • GD library doesn't support SVG. It's the most common library and Drupal uses it as the default image processing library.
  • ImageMagick supports SVG, but requires to have ImageMagick binaries installed on the server (less common). It is also supported by Drupal.
  • Cairo supports SVG, but like ImageMagick it requires to have Cairo installed on the server. Not supported by Drupal.

Also, some image operations do not make sense with vector graphics formats (resize, etc). And what about some SVG features like animation?

Finally, there are several versions of the SVG specification and SVG support varies greatly between browsers - see http://en.wikipedia.org/wiki/Comparison_of_layout_engines_%28Scalable_Ve... .

IMHO there are several issues to iron out first before being able to implement support for vector graphics formats in Drupal.

Dave-B’s picture

I would suggest a getting a basic level of support in at first, where the .svg file is handled without making any modifications (e.g. scale, crop) to the file.

Enable just the simple case of uploading a .svg image, and displaying it in an image element, and later implement scaling, etc. where it makes sense.

josegaert’s picture

I began writing a module to add svg support.
But beware, It is the first module I ever wrote for Drupal, so don't expect fancy stuff.

Because the project that requires me to have svg support will handle a lot of svg and change the svg a lot, I've chosen to save the svg code in a field in the database, and not as separate files.

While the module still lacks many basic functions, like good verification, file uploading, etc.. I've already implemented support for some image styles. And that is pretty easy. By encapsulating one svg into another you can get pretty far.

Now, I'm looking for an interested mentor, to help me integrating my svg module deep into the image-module. I want my module to extend image module to the point that svg images will be handled indifferently from other pictures (for the end user).

EDIT: http://drupal.org/sandbox/josegaert/1511596

loominade’s picture

Component: base system » image system

this should be a feature request for the image.module. shouldn't it?

claudiu.cristea’s picture

Status: Active » Closed (won't fix)

This has to be done with a contrib/custom module by implementing ImageToolkitInterface and providing a new (or extended) toolkit that is able to handle the required image type.

Core will not implement new image types. At least not in 8 release.

yannickoo’s picture

Version: 8.x-dev » 9.x-dev
Status: Closed (won't fix) » Active

Let us reopen this issue and move that to Drupal 9. Sure it would be a contrib module in 8.

jwilson3’s picture