Skip to content

Commit

Permalink
error handling for imagick demo image in settings and imagick version…
Browse files Browse the repository at this point in the history
… number in settings / #16
  • Loading branch information
AndiLeni committed Oct 17, 2023
1 parent 8fbdb53 commit 22f6328
Showing 1 changed file with 23 additions and 11 deletions.
34 changes: 23 additions & 11 deletions pages/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@
} else {
echo '<p class="text-danger bold"><b>Imagick kann kein AVIF</b></p>';
}

$imagickVersion = Imagick::getVersion()["versionString"];
echo "<p>Imagick Version: " . $imagickVersion . "</p>";
} else {
echo '<p class="text-danger bold"><b>Imagick ist nicht installiert</b></p>';
}
Expand Down Expand Up @@ -100,17 +103,26 @@
}

if (class_exists(Imagick::class)) {
$image = new Imagick($demo_img);
$image->setImageFormat('webp');
$imageData = $image->getImageBlob();
$imageDataBase64 = base64_encode($imageData);
echo '<p>Imagick webp: <img class="img-thumbnail" src="data:image/webp;base64,' . $imageDataBase64 . '"></p>';

$image = new Imagick($demo_img);
$image->setImageFormat('avif');
$imageData = $image->getImageBlob();
$imageDataBase64 = base64_encode($imageData);
echo '<p>Imagick avif: <img class="img-thumbnail" src="data:image/avif;base64,' . $imageDataBase64 . '"></p>';
try {
$image = new Imagick($demo_img);
$image->setImageFormat('webp');
$imageData = $image->getImageBlob();
$imageDataBase64 = base64_encode($imageData);
echo '<p>Imagick webp: <img class="img-thumbnail" src="data:image/webp;base64,' . $imageDataBase64 . '"></p>';
} catch (Exception $e) {
echo rex_view::error($e->getMessage());
}

try {
$image = new Imagick($demo_img);
$image->setImageFormat('avif');
$imageData = $image->getImageBlob();
$imageDataBase64 = base64_encode($imageData);
echo '<p>Imagick avif: <img class="img-thumbnail" src="data:image/avif;base64,' . $imageDataBase64 . '"></p>';
echo '<p>Imagick webp: <img class="img-thumbnail" src="data:image/webp;base64,' . $imageDataBase64 . '"></p>';
} catch (Exception $e) {
echo rex_view::error($e->getMessage());
}
}

?>

0 comments on commit 22f6328

Please sign in to comment.