Voting

: min(nine, three)?
(Example: nine)

The Note You're Voting On

matthieu dot poignant+php at gmail dot com
3 years ago
In PHP 8, you can create an image based on the popular image types without worrying about what it is:

<?php
function imageCreateFromAny($filepath): ?\GdImage {
return match (
exif_imagetype($filepath)) {
// gif
1 => imageCreateFromGif($filepath),
// jpg
2 => imageCreateFromJpeg($filepath),
// png
3 => imageCreateFromPng($filepath),
// bmp
6 => imageCreateFromBmp($filepath),
// not defined
default => null,
};
}
?>

<< Back to user notes page

To Top