Workaround for https://bugs.php.net/bug.php?id=66339 for imagexbm on PHP 5.5
parent
ea96de853e
commit
4005bb69cb
|
@ -37,12 +37,21 @@ try {
|
||||||
throw new Exception("{$saveFuntion}() function is missing");
|
throw new Exception("{$saveFuntion}() function is missing");
|
||||||
}
|
}
|
||||||
$tempFile = tempnam(sys_get_temp_dir(), 'dpei');
|
$tempFile = tempnam(sys_get_temp_dir(), 'dpei');
|
||||||
|
ob_start();
|
||||||
if ($saveFuntion($image, $tempFile) === false) {
|
if ($saveFuntion($image, $tempFile) === false) {
|
||||||
throw new Exception("{$saveFuntion}() failed");
|
throw new Exception("{$saveFuntion}() failed");
|
||||||
}
|
}
|
||||||
if (!is_file($tempFile) || filesize($tempFile) < 1) {
|
$contents = ob_get_contents();
|
||||||
|
ob_end_clean();
|
||||||
|
if (!is_file($tempFile)) {
|
||||||
|
throw new Exception("{$saveFuntion}() didn't create a file");
|
||||||
|
}
|
||||||
|
if (filesize($tempFile) < 1) {
|
||||||
|
if ($format !== 'xbm' || PHP_VERSION_ID >= 50600 || $contents === '') {
|
||||||
throw new Exception("{$saveFuntion}() created an empty file");
|
throw new Exception("{$saveFuntion}() created an empty file");
|
||||||
}
|
}
|
||||||
|
file_put_contents($tempFile, $contents);
|
||||||
|
}
|
||||||
$image2 = $loadFuntion($tempFile);
|
$image2 = $loadFuntion($tempFile);
|
||||||
unlink($tempFile);
|
unlink($tempFile);
|
||||||
$tempFile = null;
|
$tempFile = null;
|
||||||
|
|
Loading…
Reference in New Issue