After read the answers for: Convert SVG image to PNG with PHP Convert SVG to PNG image Convert a bunch of images from svg to png I finally get a working code, at my lab it works fine but when I upload that to my server, the script fails.
The function I use is the following:
function svg2png($svg, $nomarchpng, $parametros = null) {
$im = new Imagick();
$im->readImageBlob($svg);
$im->setImageFormat("png32");
if (isset($parametros->ancho) && isset($parametros->alto))
$im->resizeImage( $parametros->ancho
, $parametros->alto
, imagick::FILTER_LANCZOS
, 1);
$im->writeImage($nomarchpng);
$im->clear();
$im->destroy();
}
At my lab, a linux Mageia machine with php 5.6.33 and imagick module version 3.4.1 imagick classes Imagick, ImagickDraw, ImagickPixel, ImagickPixelIterator, ImagickKernel Imagick compiled with ImageMagick version ImageMagick 6.9.8-7 Q16 x86_64 2017-05-27
On that environment the resulting png looks pretty good.
But when I upload that script to my server the resulting png is a blank png with the right dimentions and white background.
The server is a FreeBSD with PHP Version 5.6.33 imagick module version 3.4.3 imagick classes Imagick, ImagickDraw, ImagickPixel, ImagickPixelIterator, ImagickKernel Imagick compiled with ImageMagick version ImageMagick 6.9.9-28 Q16 amd64 2018-02-23
I tought that maybe the problem was related with charsets, then I force php with ini_set('default_charset', 'utf8'); but png still blanck.
Could you tell me a clue... maybe how to debug the png generation in order to see what is happening step by step.
Thanks in advance.