Added automatic check for imageick extension and usage

master
Kubwa 2020-11-29 17:26:32 +01:00
parent d9d6161fa9
commit 981fce35a0
1 changed files with 8 additions and 2 deletions

View File

@ -262,8 +262,14 @@
$AssetImageData = HttpRequest($AssetURI, "", "", 3); $AssetImageData = HttpRequest($AssetURI, "", "", 3);
$TempName = $this->MySql->id(8); $TempName = $this->MySql->id(8);
file_put_contents("binary_helper/".$TempName.".jp2", $AssetImageData); file_put_contents("binary_helper/".$TempName.".jp2", $AssetImageData);
//Should be the same for Windows and Unix... If not, only God can help you... or Google (which is the same) if (extension_loaded("imagick"))
shell_exec("binary_helper".DIRECTORY_SEPARATOR."magick convert binary_helper/".$TempName.".jp2 binary_helper/".$TempName.".jpg"); {
$Image = new Imagick(realpath("./binary_helper/".$TempName.".jp2"));
$Image->setImageFormat("jpg");
$Image->writeImage(realpath("./binary_helper/".$TempName.".jpg"));
}
else
{shell_exec("binary_helper".DIRECTORY_SEPARATOR."magick convert binary_helper/".$TempName.".jp2 binary_helper/".$TempName.".jpg");}
$AssetImageData = file_get_contents("binary_helper/".$TempName.".jpg"); $AssetImageData = file_get_contents("binary_helper/".$TempName.".jpg");
@unlink("binary_helper/".$TempName.".jp2"); @unlink("binary_helper/".$TempName.".jp2");
@unlink("binary_helper/".$TempName.".jpg"); @unlink("binary_helper/".$TempName.".jpg");