Esi\Utility\Image
guessImageType(string $imagePath): string | false; |
// Just helper functions for guessImageType()
guessImageTypeExif(string $imagePath): string | false;
guessImageTypeFinfo(string $imagePath): string | false;
guessImageTypeGetImageSize(string $imagePath): string | false;
Check if the GD library is available on the server.
use Esi\Utility\Image;
if (Image::isGdAvailable() {
// ... run some GD related code here...
}
Check if the GraphicsMagick library is available on the server.
use Esi\Utility\Image;
if (Image::isGmagickAvailable() {
// ... run some GD related code here...
}
Check if the ImageMagick library is available on the server.
use Esi\Utility\Image;
if (Image::isImagickAvailable() {
// ... run some GD related code here...
}
Check if the Exif extension is available on the server.
use Esi\Utility\Image;
if (Image::isExifAvailable() {
// ... run some GD related code here...
}
Attempts to determine the image type. It tries to determine the image type with, in order of preference: Exif, finfo, and getimagesize.
use Esi\Utility\Image;
echo Image::guessImageType('/some/folder/image.jpg'); // 'image/jpeg'
Checks if image has JPG format.
use Esi\Utility\Image;
var_dump(Image::isJpg('/some/folder/image.jpg')); // bool(true)
Checks if image has GIF format.
use Esi\Utility\Image;
var_dump(Image::isGif('/some/folder/image.gif')); // bool(true)
Checks if image has PNG format.
use Esi\Utility\Image;
var_dump(Image::isPng('/some/folder/image.png')); // bool(true)
Checks if image has WEBP format.
use Esi\Utility\Image;
var_dump(Image::isWebp('/some/folder/image.webp')); // bool(true)