GdEngine
extends ImageEngine
in package
Table of Contents
Methods
- __construct() : mixed
- Image Helper constructor.
- computeEditMetrics() : array<string|int, mixed>
- 画像編集をするための数値を計算
- copyImage() : void
- 画像を複製
- copyImageAsWebp() : void
- WebP画像として画像を複製
- detectImageExtenstion() : string
- MIMEタイプから画像拡張子を検出する
- editImage() : void
- 画像を編集(リサイズ・回転)して書き出す
- getImageQuality() : int
- 画質を取得
- getImageSize() : array{0: int, 1: int, 2: int, 3: string, bits: int, channels: int, mime: string}|false
- 画像パスから画像サイズを取得
- getMimeType() : string|null
- 画像パスからMIMETypeを取得
- getSize() : array{0: int, 1: int}
- 画像サイズを取得
- isUploadedFile() : bool
- アップロードされたファイルかどうか判定
- isWebpSupported() : bool
- GDでWebP画像がサポートされているか判定
- optimize() : void
- ロスレス圧縮を実行
- resizeImage() : void
- 画像をリサイズ
- setImageQuality() : void
- 画質をセット
- setOptimizer() : void
- 画像オプティマイザーを設定
- uniqueFilePath() : string
- ユニークなファイルパスを生成
- loadGdImageFromPath() : GdImage
- 画像パスからGDImage or resourceを生成
- mimeTypeToExtension() : string|T
- 画像パスから画像拡張子を取得
- outputImage() : void
- 画像ファイルを書き出し
Methods
__construct()
Image Helper constructor.
public
__construct() : mixed
computeEditMetrics()
画像編集をするための数値を計算
public
computeEditMetrics(int $srcWidth, int $srcHeight[, int|null $width = null ][, int|null $height = null ][, int|null $size = null ]) : array<string|int, mixed>
Parameters
- $srcWidth : int
- $srcHeight : int
- $width : int|null = null
- $height : int|null = null
- $size : int|null = null
Return values
array<string|int, mixed> —{ width: int, height: int, x: int, y: int, columns: int, rows: int }
copyImage()
画像を複製
public
copyImage(string $srcPath, string $destPath[, string|null $format = null ]) : void
Parameters
- $srcPath : string
- $destPath : string
- $format : string|null = null
copyImageAsWebp()
WebP画像として画像を複製
public
copyImageAsWebp(string $srcPath, string $destPath) : void
Parameters
- $srcPath : string
- $destPath : string
detectImageExtenstion()
MIMEタイプから画像拡張子を検出する
public
detectImageExtenstion(string $mimeType) : string
Parameters
- $mimeType : string
Return values
stringeditImage()
画像を編集(リサイズ・回転)して書き出す
public
editImage(string $srcPath, string $destPath[, int|null $width = null ][, int|null $height = null ][, int|null $size = null ][, int|null $angle = null ]) : void
Parameters
- $srcPath : string
- $destPath : string
- $width : int|null = null
- $height : int|null = null
- $size : int|null = null
- $angle : int|null = null
getImageQuality()
画質を取得
public
getImageQuality() : int
Return values
intgetImageSize()
画像パスから画像サイズを取得
public
getImageSize(string $path) : array{0: int, 1: int, 2: int, 3: string, bits: int, channels: int, mime: string}|false
Parameters
- $path : string
Return values
array{0: int, 1: int, 2: int, 3: string, bits: int, channels: int, mime: string}|falsegetMimeType()
画像パスからMIMETypeを取得
public
getMimeType(string $path) : string|null
Parameters
- $path : string
Return values
string|nullgetSize()
画像サイズを取得
public
getSize(string $path) : array{0: int, 1: int}
Parameters
- $path : string
Return values
array{0: int, 1: int}isUploadedFile()
アップロードされたファイルかどうか判定
public
isUploadedFile(string $path) : bool
Parameters
- $path : string
Return values
boolisWebpSupported()
GDでWebP画像がサポートされているか判定
public
isWebpSupported() : bool
Return values
booloptimize()
ロスレス圧縮を実行
public
optimize(string $path) : void
Parameters
- $path : string
resizeImage()
画像をリサイズ
public
resizeImage(string $srcPath, string $destPath, int $srcWidth, int $srcHeight, int $srcX, int $srcY, int $destWidth, int $destHeight, int $destX, int $destY, int $canvasWidth, int $canvasHeight, array{0: int, 1: int, 2: int} $color[, int|null $angle = null ]) : void
Parameters
- $srcPath : string
- $destPath : string
- $srcWidth : int
- $srcHeight : int
- $srcX : int
- $srcY : int
- $destWidth : int
- $destHeight : int
- $destX : int
- $destY : int
- $canvasWidth : int
- $canvasHeight : int
- $color : array{0: int, 1: int, 2: int}
- $angle : int|null = null
setImageQuality()
画質をセット
public
setImageQuality(int $quality) : void
Parameters
- $quality : int
setOptimizer()
画像オプティマイザーを設定
public
setOptimizer(ImagerOptimizer $optimizer) : void
Parameters
- $optimizer : ImagerOptimizer
uniqueFilePath()
ユニークなファイルパスを生成
public
uniqueFilePath(string $path, string $prefix) : string
Parameters
- $path : string
- $prefix : string
Return values
stringloadGdImageFromPath()
画像パスからGDImage or resourceを生成
protected
loadGdImageFromPath(string $path) : GdImage
Parameters
- $path : string
Tags
Return values
GdImagemimeTypeToExtension()
画像パスから画像拡張子を取得
protected
mimeTypeToExtension(string $mimeType[, T $fallback = 'jpg' ]) : string|T
Parameters
- $mimeType : string
- $fallback : T = 'jpg'
Tags
Return values
string|ToutputImage()
画像ファイルを書き出し
protected
outputImage(GdImage|false $resource, string $imageType, string $destPath) : void
Parameters
- $resource : GdImage|false
- $imageType : string
- $destPath : string