1

On my MAMP development server, SVG files display like this in the Assets section of the Control Panel:

enter image description here

On my live server, they get a black background: enter image description here

When I use an SVG file inside an img tag with an transform like this:

<img src="{{ iconSVG.getUrl(iconSize) }}">

I got this working fine on the MAMP server, but on the live server the file gets transformed into a PNG with a black background.

I don't necessarily have to use a transform on the SVGs, so could leave that out, but the black thumbs in the Assets isn't that pretty.

I checked both servers, and a possibly relevant difference I can see is that the MAMP does not have imagick, whereas the live server does.

How can I fix the black thumbnail issue? Would I need to disable imagick on the live server somehow?

3
  • I think Craft will prefer GD if it is installed, and only fall back on imagick, so I'd start checking if the live env has GD installed. I can also vaguely remember a similar issue with imagemagick and CMYK colors, but I can't remember any specifics. – megatrond Jul 24 '15 at 10:01
  • @megatrond Close! Craft will prefer Imagick and fall back to GD if it's not available. – Brad Bell Jul 24 '15 at 17:51
  • Oh, I had it backwards then! I still can remember something about CMYK and black results from imagemagick though. – megatrond Jul 24 '15 at 18:03
1

Craft requires Imagick to do any SVG transforms, so that fact that it is working on your MAMP install without it is the only weird thing I see here. :)

Craft will attempt to use Imagick if it is available on the server and fallback to GD otherwise or you can explicitly tell it which one to use via the imageDriver config setting.

As to why it's all black on production, make sure you're using a recent version of both the Imagick PHP extension as well as the underlying Imagick library.

1
  • Thanks Brad. I've added the 'imageDriver' => 'gd' setting to the config file and now get the default SVG file icon in the assets area, which isn't perfect but better than a black square :) I've asked my host to upgrade ImageMagick, as the current version on the server I use is from 2012. – Katrin Jul 27 '15 at 11:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.