mirror of
https://github.com/Intervention/image.git
synced 2025-08-28 08:09:54 +02:00
Add methods
This commit is contained in:
@@ -29,7 +29,7 @@ class TextModifier extends AbstractTextModifier
|
|||||||
foreach ($lines as $line) {
|
foreach ($lines as $line) {
|
||||||
imagettftext(
|
imagettftext(
|
||||||
$frame->native(),
|
$frame->native(),
|
||||||
$this->adjustedSize(),
|
$this->adjustedFontSize(),
|
||||||
$this->font->angle() * -1,
|
$this->font->angle() * -1,
|
||||||
$line->position()->x(),
|
$line->position()->x(),
|
||||||
$line->position()->y(),
|
$line->position()->y(),
|
||||||
@@ -75,7 +75,7 @@ class TextModifier extends AbstractTextModifier
|
|||||||
|
|
||||||
// calculate box size from font file with angle 0
|
// calculate box size from font file with angle 0
|
||||||
$box = imageftbbox(
|
$box = imageftbbox(
|
||||||
$this->adjustedSize(),
|
$this->adjustedFontSize(),
|
||||||
0,
|
0,
|
||||||
$this->font->filename(),
|
$this->font->filename(),
|
||||||
$text
|
$text
|
||||||
@@ -91,7 +91,7 @@ class TextModifier extends AbstractTextModifier
|
|||||||
return $polygon;
|
return $polygon;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function adjustedSize(): float
|
private function adjustedFontSize(): float
|
||||||
{
|
{
|
||||||
return floatval(ceil($this->font->size() * .75));
|
return floatval(ceil($this->font->size() * .75));
|
||||||
}
|
}
|
||||||
|
@@ -26,6 +26,8 @@ use Intervention\Image\Interfaces\ModifierInterface;
|
|||||||
use Intervention\Image\Interfaces\ProfileInterface;
|
use Intervention\Image\Interfaces\ProfileInterface;
|
||||||
use Intervention\Image\Interfaces\ResolutionInterface;
|
use Intervention\Image\Interfaces\ResolutionInterface;
|
||||||
use Intervention\Image\Interfaces\SizeInterface;
|
use Intervention\Image\Interfaces\SizeInterface;
|
||||||
|
use Intervention\Image\Modifiers\GreyscaleModifier;
|
||||||
|
use Intervention\Image\Modifiers\PixelateModifier;
|
||||||
use Intervention\Image\Modifiers\SharpenModifier;
|
use Intervention\Image\Modifiers\SharpenModifier;
|
||||||
use Intervention\Image\Modifiers\TextModifier;
|
use Intervention\Image\Modifiers\TextModifier;
|
||||||
use Intervention\Image\Typography\FontFactory;
|
use Intervention\Image\Typography\FontFactory;
|
||||||
@@ -134,6 +136,16 @@ class Image implements ImageInterface, Countable
|
|||||||
return $this->modify(new SharpenModifier($amount));
|
return $this->modify(new SharpenModifier($amount));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function pixelate(int $size): ImageInterface
|
||||||
|
{
|
||||||
|
return $this->modify(new PixelateModifier($size));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function greyscale(): ImageInterface
|
||||||
|
{
|
||||||
|
return $this->modify(new GreyscaleModifier());
|
||||||
|
}
|
||||||
|
|
||||||
public function text(string $text, int $x, int $y, callable|FontInterface $font): ImageInterface
|
public function text(string $text, int $x, int $y, callable|FontInterface $font): ImageInterface
|
||||||
{
|
{
|
||||||
return $this->modify(
|
return $this->modify(
|
||||||
|
@@ -19,9 +19,13 @@ interface ImageInterface extends IteratorAggregate, Countable
|
|||||||
public function isAnimated(): bool;
|
public function isAnimated(): bool;
|
||||||
public function loops(): int;
|
public function loops(): int;
|
||||||
public function exif(?string $query = null): mixed;
|
public function exif(?string $query = null): mixed;
|
||||||
|
public function resolution(): ResolutionInterface;
|
||||||
public function colorspace(): ColorspaceInterface;
|
public function colorspace(): ColorspaceInterface;
|
||||||
public function pickColor(int $x, int $y, int $frame_key = 0): ColorInterface;
|
public function pickColor(int $x, int $y, int $frame_key = 0): ColorInterface;
|
||||||
public function pickColors(int $x, int $y): CollectionInterface;
|
public function pickColors(int $x, int $y): CollectionInterface;
|
||||||
public function profile(): ProfileInterface;
|
public function profile(): ProfileInterface;
|
||||||
public function sharpen(int $amount = 10): ImageInterface;
|
public function sharpen(int $amount = 10): ImageInterface;
|
||||||
|
public function greyscale(): ImageInterface;
|
||||||
|
public function pixelate(int $size): ImageInterface;
|
||||||
|
public function text(string $text, int $x, int $y, callable|FontInterface $font): ImageInterface;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user