Update Composer packages

This commit is contained in:
Paul Nicoué 2025-01-12 18:56:44 +01:00
parent a80f1abaa4
commit 0a904482ae
41 changed files with 922 additions and 679 deletions

View file

@ -116,15 +116,33 @@ class SimpleImage
*/
public function __destruct()
{
if ($this->image instanceof GdImage) {
imagedestroy($this->image);
}
$this->reset();
}
//////////////////////////////////////////////////////////////////////////////////////////////////
// Helper functions
//////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Checks if the SimpleImage object has loaded an image.
*/
public function hasImage(): bool
{
return $this->image instanceof GdImage;
}
/**
* Destroys the image resource.
*/
public function reset(): static
{
if ($this->hasImage()) {
imagedestroy($this->image);
}
return $this;
}
/**
* Set flag value.
*
@ -313,7 +331,7 @@ class SimpleImage
*
* @throws Exception Thrown when WEBP support is not enabled or unsupported format.
*/
protected function generate(string $mimeType = null, array|int $options = []): array
public function generate(string $mimeType = null, array|int $options = 100): array
{
// Format defaults to the original mime type
$mimeType = $mimeType ?: $this->mimeType;
@ -1616,12 +1634,12 @@ class SimpleImage
* @param int $width The ellipse width.
* @param int $height The ellipse height.
* @param string|array $color The ellipse color.
* @param int|array $thickness Line thickness in pixels or 'filled' (default 1).
* @param string|int|array $thickness Line thickness in pixels or 'filled' (default 1).
* @return SimpleImage
*
* @throws Exception
*/
public function ellipse(int $x, int $y, int $width, int $height, string|array $color, int|array $thickness = 1): static
public function ellipse(int $x, int $y, int $width, int $height, string|array $color, string|int|array $thickness = 1): static
{
// Allocate the color
$tempColor = $this->allocateColor($color);
@ -2337,18 +2355,24 @@ class SimpleImage
$hex = strval(preg_replace('/^#/', '', $color));
// Support short and standard hex codes
if (strlen($hex) === 3) {
if (strlen($hex) === 3 || strlen($hex) === 4) {
[$red, $green, $blue] = [
$hex[0].$hex[0],
$hex[1].$hex[1],
$hex[2].$hex[2],
];
} elseif (strlen($hex) === 6) {
if (strlen($hex) === 4) {
$alpha = hexdec($hex[3]) / 255;
}
} elseif (strlen($hex) === 6 || strlen($hex) === 8) {
[$red, $green, $blue] = [
$hex[0].$hex[1],
$hex[2].$hex[3],
$hex[4].$hex[5],
];
if (strlen($hex) === 8) {
$alpha = hexdec($hex[6].$hex[7]) / 255;
}
} else {
throw new Exception("Invalid color value: $color", self::ERR_INVALID_COLOR);
}