function svg_embed_fallback_png in SVG Embed 7
Menu callback to localise and convert the SVG to PNG which will then be delivered to the requesting browser.
Parameters
string $langcode:
stdClass $file:
1 string reference to 'svg_embed_fallback_png'
- svg_embed_menu in ./
svg_embed.module - Implements hook_menu().
File
- ./
svg_embed.module, line 265 - SVG Embed. Provides a filter for text formats that includes and on the fly translates SVG files into text fields.
Code
function svg_embed_fallback_png($langcode, $file) {
if (!class_exists('Imagick')) {
drupal_not_found();
exit;
}
$svg = _svg_embed_get_svg($file, $langcode, FALSE);
$im = new Imagick();
$im
->readImageBlob($svg);
$im
->setImageFormat("png24");
header("Content-Type: image/png");
print $im
->getImagesBlob();
exit;
}