PHP Classes

File: docs/image.md

Recommend this page to a friend!
  Classes of Eric Sizemore   Utility   docs/image.md   Download  
File: docs/image.md
Role: Auxiliary data
Content type: text/markdown
Description: Auxiliary data
Class: Utility
Collection of various PHP utility functions
Author: By
Last change:
Date: 2 months ago
Size: 2,345 bytes
 

Contents

Class file image Download

Image

Esi\Utility\Image

@access private

// Just helper functions for guessImageType()
guessImageTypeExif(string $imagePath): string | false;
guessImageTypeFinfo(string $imagePath): string | false;
guessImageTypeGetImageSize(string $imagePath): string | false;

isGdAvailable

Check if the GD library is available on the server.

use Esi\Utility\Image;

if (Image::isGdAvailable() {
    // ... run some GD related code here...
}

isGmagickAvailable

Check if the GraphicsMagick library is available on the server.

use Esi\Utility\Image;

if (Image::isGmagickAvailable() {
    // ... run some GD related code here...
}

isImagickAvailable

Check if the ImageMagick library is available on the server.

use Esi\Utility\Image;

if (Image::isImagickAvailable() {
    // ... run some GD related code here...
}

isExifAvailable

Check if the Exif extension is available on the server.

use Esi\Utility\Image;

if (Image::isExifAvailable() {
    // ... run some GD related code here...
}

guessImageType

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'

isJpg

Checks if image has JPG format.

use Esi\Utility\Image;

var_dump(Image::isJpg('/some/folder/image.jpg')); // bool(true)

isGif

Checks if image has GIF format.

use Esi\Utility\Image;

var_dump(Image::isGif('/some/folder/image.gif')); // bool(true)

isPng

Checks if image has PNG format.

use Esi\Utility\Image;

var_dump(Image::isPng('/some/folder/image.png')); // bool(true)

isWebp

Checks if image has WEBP format.

use Esi\Utility\Image;

var_dump(Image::isWebp('/some/folder/image.webp')); // bool(true)