Trying to convert a TIFF in PHP. We have ImageMagick installed on our server but we do not have the Imagick PECL extension (and we're on shared hosting on GoDaddy so I don't think it's possible to install).
I'm trying to find a workaround but no luck yet. Here's what I have so far (note that the TIFFs come to us in the form of a base64 string):
$tiff = base64_decode((string)$docsData);
try {
$cmd = "$tiff converted.png";
exec("/usr/local/bin/convert $cmd");
}
catch(Exception $e) {
die('Error when creating a file: ' . $e->getMessage());
}
You can't just dump the raw binary "garbage" of a tiff as an argument on the command line. You're essentially trying to do
/usr/local/bin/convert $@#Wrkjd;fgldhjesr;3qjw;aesrfkj .... converted.png
Dump that "garbage" to a file, then use that file:
$tempname = tempnam();
file_put_contents($tempname, base64_decode($docsData);
exec("/usr/loca/bin/convert $tempname converted.png");
unlink($tempname);