Menu

## Image
in package

Image.php : 19

Class Image A class for image manipulation.

##### Tags

see
  https://www.kotchasan.com/

### Table of Contents

$quality : int
crop() : bool
  Crop an image to the specified size.
flip() : GdImage
  Flip an image horizontally.
info() : array<string|int, mixed>|bool
  Retrieve image information.
orient() : mixed
resize() : array<string|int, mixed>|false
  Resize an image and optionally add a watermark.
setQuality() : mixed
  Set the image quality for JPEG images.
watermarkText() : GdImage
  Add a text watermark to an image.
flipImage() : mixed
rotateImage() : mixed

### Properties

#### $quality

Image.php : 24
`private static int $quality = 75`

The image quality (0-100) for JPEG or WEBP images.

### Methods

#### crop()

Image.php : 41

Crop an image to the specified size.

`public static crop(string $source, string $target, int $thumbwidth, int $thumbheight[, string $watermark = '' ]) : bool`

The resulting image will have the exact dimensions specified. If the original image has a different aspect ratio, it will be cropped or stretched to fit the target dimensions. The resulting image will be saved as a JPEG or WEBP file.

##### Parameters

$source : string

  The path and filename of the source image.

$target : string

  The path and filename of the target image.

$thumbwidth : int

  The desired width of the target image.

$thumbheight : int

  The desired height of the target image.

$watermark : string = ''

  (optional) The watermark text.

##### Return values

bool —

True on success, false on failure.

#### flip()

Image.php : 137

Flip an image horizontally.

`public static flip(GdImage $imgsrc) : GdImage`

This method flips the specified image horizontally.

##### Parameters

$imgsrc : GdImage

  The source image resource.

##### Return values

GdImage —

The flipped image resource.

#### info()

Image.php : 166

Retrieve image information.

`public static info(string $source) : array<string|int, mixed>|bool`

This method retrieves the width, height, and MIME type of an image using the `getimagesize()` function.

##### Parameters

$source : string

  The path and filename of the image.

##### Return values

array<string|int, mixed>|bool —

An array containing the image properties (width, height, and mime) on success, or false if the information cannot be obtained.

#### orient()

Image.php : 184
`public static orient( $source) : mixed`

##### Parameters

$source :

##### Return values

mixed —

#### resize()

Image.php : 273

Resize an image and optionally add a watermark.

`public static resize(string $source, string $target, string $name, int $width[, string $watermark = '' ]) : array<string|int, mixed>|false`

This method resizes the specified image to the given width while maintaining aspect ratio. It can also add a watermark to the resized image if specified.

##### Parameters

$source : string

  The path to the source image.

$target : string

  The path to save the resized image.

$name : string

  The name of the resized image.

$width : int

  The desired width for the resized image.

$watermark : string = ''

  Optional. The watermark text to add to the resized image. Default is an empty string.

##### Return values

array<string|int, mixed>|false —

An array containing information about the resized image if successful, false otherwise. The returned array will have the following keys:

- 'name': The name of the resized image.
- 'width': The width of the resized image.
- 'height': The height of the resized image.
- 'mime': The MIME type of the resized image ('image/jpeg' for JPEG images).

#### setQuality()

Image.php : 405

Set the image quality for JPEG images.

`public static setQuality(int $quality) : mixed`

This method sets the quality level (0-100) for JPEG images. Higher quality values result in larger file sizes but better image quality. The default value is 75.

##### Parameters

$quality : int

  The image quality level (0-100).

##### Return values

mixed —

#### watermarkText()

Image.php : 369

Add a text watermark to an image.

`public static watermarkText(GdImage $imgsrc, string $text[, string $pos = '' ][, string $color = 'CCCCCC' ][, int $font_size = 20 ][, int $opacity = 50 ]) : GdImage`

This method adds a text watermark to the specified image. The watermark text, position, color, font size, and opacity can be customized.

##### Parameters

$imgsrc : GdImage

  The source image resource.

$text : string

  The text to be used as the watermark.

$pos : string = ''

  The position of the watermark. Valid values: 'center', 'bottom', 'left', 'right' (default: '').

$color : string = 'CCCCCC'

  The color of the watermark in hexadecimal format (default: 'CCCCCC').

$font_size : int = 20

  The font size of the watermark (default: 20).

$opacity : int = 50

  The opacity of the watermark (0-100) (default: 50).

##### Return values

GdImage —

The modified image resource with the added watermark.

#### flipImage()

Image.php : 249
`private static flipImage( $image) : mixed`

##### Parameters

$image :

##### Return values

mixed —

#### rotateImage()

Image.php : 241
`private static rotateImage( $image, $angle) : mixed`

##### Parameters

$image :
$angle :

##### Return values

mixed —

## Search results