You are here

protected function MediaThumbnailSVG::createThumbnailGM in Media Thumbnails SVG 8

1 call to MediaThumbnailSVG::createThumbnailGM()
MediaThumbnailSVG::createThumbnail in src/Plugin/MediaThumbnail/MediaThumbnailSVG.php
Creates a managed thumbnail file using the passed source file uri.

File

src/Plugin/MediaThumbnail/MediaThumbnailSVG.php, line 59

Class

MediaThumbnailSVG
Media thumbnail plugin for svg documents.

Namespace

Drupal\media_thumbnails_svg\Plugin\MediaThumbnail

Code

protected function createThumbnailGM($path) {
  $source = escapeshellarg($path);
  $target = $source . '.png';
  shell_exec("gm convert -background '{$this->bg_color}' -size {$this->width} -quality 100 -strip {$source} {$target}");
  $data = file_get_contents($path . '.png');
  if (!$data) {
    $this->logger
      ->warning($this
      ->t('Could not create png from svg using GM.'));
  }
  return $data;
}