Helper
in package
Table of Contents
Properties
Methods
- __construct() : mixed
- コンストラクター
- copyImage() : bool
- 画像の複製
- createImages() : array{path: string, type: string, name: string, size: string, filesize: int}
- サイズ違い(tiny, square, large, normal)の画像を生成
- deleteImageAllSize() : void
- 全サイズの画像削除
- detectImageExtenstion() : string
- 画像パスから画像タイプを取得
- getImageDimensions() : array<string|int, mixed>|null
- 画像の幅と高さを取得
- resizeImg() : void
- 画像のリサイズ
- createCreateImagesConfig() : array{edit: array{tiny: array{size: int, angle?: int, side?: "w"|"h"|"width"|"height"}, square?: array{size: int, angle?: int|null}, normal: array{size: int, angle?: int, side?: "w"|"h"|"width"|"height"}, large?: array{size: int, angle?: int, side?: "w"|"h"|"width"|"height"}}, srcPath: string, destPath: string, path: string, ext: "gif"|"png"|"bmp"|"xbm"|"jpg", fileName: string}
- createResizedImages() : array{path: string, type: string, name: string, size: string, filesize: int}
- parseSvgLength() : float|null
- SVGの長さをパースして、ピクセル値を返す
- assertNonNegativeDimension() : void
- width / height / size の値が指定されていて負数なら InvalidArgumentException を投げる
Properties
$engine
private
ImageEngine
$engine
Methods
__construct()
コンストラクター
public
__construct() : mixed
copyImage()
画像の複製
public
copyImage(string $from, string $to[, int|null $width = null ][, int|null $height = null ][, int|null $size = null ][, int|null $angle = null ]) : bool
仕様:
- 縮小のみを行う。width/height/size のいずれも src の対応する次元より大きい場合、 リサイズせず元サイズのままコピーする(拡大はしない)。
- 戻り値 true は本体ファイルの書き出し成功のみを保証する。webp 同時生成 (copyImageAsWebp 経路)の失敗は内部で握りつぶされ戻り値には反映されない。
Parameters
- $from : string
- $to : string
- $width : int|null = null
-
0 以上または null。負数は InvalidArgumentException。0 は「未指定」相当でリサイズしない
- $height : int|null = null
-
0 以上または null。負数は InvalidArgumentException。0 は「未指定」相当でリサイズしない
- $size : int|null = null
-
0 以上または null。負数は InvalidArgumentException。0 は「未指定」相当でリサイズしない
- $angle : int|null = null
Return values
bool —本体ファイルの書き出しに成功したか
createImages()
サイズ違い(tiny, square, large, normal)の画像を生成
public
createImages(string $filepath, string $filename, array{normal?: int, tiny?: int, large?: int, square?: int} $sizes, string $destDir[, bool $isRandomFileName = true ][, int|null $angle = null ][, bool $forceLarge = false ]) : array{path: string, type: string, name: string, size: string, filesize: int}
Parameters
- $filepath : string
- $filename : string
- $sizes : array{normal?: int, tiny?: int, large?: int, square?: int}
- $destDir : string
- $isRandomFileName : bool = true
- $angle : int|null = null
- $forceLarge : bool = false
Return values
array{path: string, type: string, name: string, size: string, filesize: int}deleteImageAllSize()
全サイズの画像削除
public
deleteImageAllSize(string $path) : void
Parameters
- $path : string
detectImageExtenstion()
画像パスから画像タイプを取得
public
detectImageExtenstion(string $mimeType) : string
Parameters
- $mimeType : string
Return values
stringgetImageDimensions()
画像の幅と高さを取得
public
getImageDimensions(string $path) : array<string|int, mixed>|null
Parameters
- $path : string
Return values
array<string|int, mixed>|nullresizeImg()
画像のリサイズ
public
resizeImg(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
-
0 以上または null。負数は InvalidArgumentException。0 は「未指定」相当
- $height : int|null = null
-
0 以上または null。負数は InvalidArgumentException。0 は「未指定」相当
- $size : int|null = null
-
0 以上または null。負数は InvalidArgumentException。0 は「未指定」相当
- $angle : int|null = null
createCreateImagesConfig()
protected
createCreateImagesConfig(string $filepath, string $filename, array{normal?: int, tiny?: int, large?: int, square?: int} $sizes, string $destDir[, bool $isRandomFileName = true ][, int|null $angle = null ][, bool $forceLarge = false ]) : array{edit: array{tiny: array{size: int, angle?: int, side?: "w"|"h"|"width"|"height"}, square?: array{size: int, angle?: int|null}, normal: array{size: int, angle?: int, side?: "w"|"h"|"width"|"height"}, large?: array{size: int, angle?: int, side?: "w"|"h"|"width"|"height"}}, srcPath: string, destPath: string, path: string, ext: "gif"|"png"|"bmp"|"xbm"|"jpg", fileName: string}
Parameters
- $filepath : string
- $filename : string
- $sizes : array{normal?: int, tiny?: int, large?: int, square?: int}
- $destDir : string
- $isRandomFileName : bool = true
- $angle : int|null = null
- $forceLarge : bool = false
Return values
array{edit: array{tiny: array{size: int, angle?: int, side?: "w"|"h"|"width"|"height"}, square?: array{size: int, angle?: int|null}, normal: array{size: int, angle?: int, side?: "w"|"h"|"width"|"height"}, large?: array{size: int, angle?: int, side?: "w"|"h"|"width"|"height"}}, srcPath: string, destPath: string, path: string, ext: "gif"|"png"|"bmp"|"xbm"|"jpg", fileName: string}createResizedImages()
protected
createResizedImages(array{edit: array{tiny: array{size: int, angle?: int, side?: "w"|"h"|"width"|"height"}, square?: array{size: int, angle?: int|null}, normal: array{size: int, angle?: int, side?: "w"|"h"|"width"|"height"}, large?: array{size: int, angle?: int, side?: "w"|"h"|"width"|"height"}}, srcPath: string, destPath: string, path: string, ext: "gif"|"png"|"bmp"|"xbm"|"jpg", fileName: string} $config) : array{path: string, type: string, name: string, size: string, filesize: int}
Parameters
- $config : array{edit: array{tiny: array{size: int, angle?: int, side?: "w"|"h"|"width"|"height"}, square?: array{size: int, angle?: int|null}, normal: array{size: int, angle?: int, side?: "w"|"h"|"width"|"height"}, large?: array{size: int, angle?: int, side?: "w"|"h"|"width"|"height"}}, srcPath: string, destPath: string, path: string, ext: "gif"|"png"|"bmp"|"xbm"|"jpg", fileName: string}
Return values
array{path: string, type: string, name: string, size: string, filesize: int}parseSvgLength()
SVGの長さをパースして、ピクセル値を返す
protected
parseSvgLength(string $value) : float|null
Parameters
- $value : string
Return values
float|nullassertNonNegativeDimension()
width / height / size の値が指定されていて負数なら InvalidArgumentException を投げる
private
assertNonNegativeDimension(int|null $value, string $name) : void
0 は「未指定 / リサイズなし」を表す既存仕様の値として許容する(Common\Helper など 既存の呼び出し側が 0 を未指定シグナルとして扱っているため)。負数だけが明らかに 不正な値として弾かれる。
Parameters
- $value : int|null
- $name : string
-
引数名(例外メッセージ用)