9090 * @method void stringUp($font, $x, $y, string $s, $col)
9191 * @method void trueColorToPalette(bool $dither, $ncolors)
9292 * @method array ttfText($size, $angle, $x, $y, $color, string $fontfile, string $text)
93- * @property-read int $width
94- * @property-read int $height
93+ * @property-read positive- int $width
94+ * @property-read positive- int $height
9595 * @property-read \GdImage $imageResource
9696 */
9797class Image
@@ -220,6 +220,8 @@ private static function invokeSafe(string $func, string $arg, string $message, s
220220
221221 /**
222222 * Creates a new true color image of the given dimensions. The default color is black.
223+ * @param positive-int $width
224+ * @param positive-int $height
223225 * @throws Nette\NotSupportedException if gd extension is not loaded
224226 */
225227 public static function fromBlank (int $ width , int $ height , ?array $ color = null ): static
@@ -247,6 +249,7 @@ public static function fromBlank(int $width, int $height, ?array $color = null):
247249
248250 /**
249251 * Returns the type of image from file.
252+ * @return ImageType::*|null
250253 */
251254 public static function detectTypeFromFile (string $ file , &$ width = null , &$ height = null ): ?int
252255 {
@@ -257,6 +260,7 @@ public static function detectTypeFromFile(string $file, &$width = null, &$height
257260
258261 /**
259262 * Returns the type of image from string.
263+ * @return ImageType::*|null
260264 */
261265 public static function detectTypeFromString (string $ s , &$ width = null , &$ height = null ): ?int
262266 {
@@ -267,6 +271,8 @@ public static function detectTypeFromString(string $s, &$width = null, &$height
267271
268272 /**
269273 * Returns the file extension for the given `ImageType::XXX` constant.
274+ * @param ImageType::* $type
275+ * @return value-of<self::Formats>
270276 */
271277 public static function typeToExtension (int $ type ): string
272278 {
@@ -280,6 +286,7 @@ public static function typeToExtension(int $type): string
280286
281287 /**
282288 * Returns the `ImageType::XXX` constant for given file extension.
289+ * @return ImageType::*
283290 */
284291 public static function extensionToType (string $ extension ): int
285292 {
@@ -295,6 +302,7 @@ public static function extensionToType(string $extension): int
295302
296303 /**
297304 * Returns the mime type for the given `ImageType::XXX` constant.
305+ * @param ImageType::* $type
298306 */
299307 public static function typeToMimeType (int $ type ): string
300308 {
@@ -314,6 +322,7 @@ public function __construct(\GdImage $image)
314322
315323 /**
316324 * Returns image width.
325+ * @return positive-int
317326 */
318327 public function getWidth (): int
319328 {
@@ -323,6 +332,7 @@ public function getWidth(): int
323332
324333 /**
325334 * Returns image height.
335+ * @return positive-int
326336 */
327337 public function getHeight (): int
328338 {
@@ -351,7 +361,7 @@ public function getImageResource(): \GdImage
351361
352362 /**
353363 * Scales an image. Width and height accept pixels or percent.
354- * @param self::OrSmaller|self::OrBigger|self::Stretch|self::Cover|self::ShrinkOnly $mode
364+ * @param int-mask-of< self::OrSmaller|self::OrBigger|self::Stretch|self::Cover|self::ShrinkOnly> $mode
355365 */
356366 public function resize (int |string |null $ width , int |string |null $ height , int $ mode = self ::OrSmaller): static
357367 {
@@ -388,7 +398,7 @@ public function resize(int|string|null $width, int|string|null $height, int $mod
388398
389399 /**
390400 * Calculates dimensions of resized image. Width and height accept pixels or percent.
391- * @param self::OrSmaller|self::OrBigger|self::Stretch|self::Cover|self::ShrinkOnly $mode
401+ * @param int-mask-of< self::OrSmaller|self::OrBigger|self::Stretch|self::Cover|self::ShrinkOnly> $mode
392402 */
393403 public static function calculateSize (
394404 int $ srcWidth ,
@@ -534,7 +544,7 @@ public function sharpen(): static
534544
535545 /**
536546 * Puts another image into this image. Left and top accepts pixels or percent.
537- * @param int $opacity 0..100
547+ * @param int<0, 100> $opacity 0..100
538548 */
539549 public function place (self $ image , int |string $ left = 0 , int |string $ top = 0 , int $ opacity = 100 ): static
540550 {
@@ -596,6 +606,7 @@ public function place(self $image, int|string $left = 0, int|string $top = 0, in
596606
597607 /**
598608 * Saves image to the file. Quality is in the range 0..100 for JPEG (default 85), WEBP (default 80) and AVIF (default 30) and 0..9 for PNG (default 9).
609+ * @param ImageType::*|null $type
599610 * @throws ImageException
600611 */
601612 public function save (string $ file , ?int $ quality = null , ?int $ type = null ): void
@@ -607,6 +618,7 @@ public function save(string $file, ?int $quality = null, ?int $type = null): voi
607618
608619 /**
609620 * Outputs image to string. Quality is in the range 0..100 for JPEG (default 85), WEBP (default 80) and AVIF (default 30) and 0..9 for PNG (default 9).
621+ * @param ImageType::* $type
610622 */
611623 public function toString (int $ type = ImageType::JPEG , ?int $ quality = null ): string
612624 {
@@ -627,6 +639,7 @@ public function __toString(): string
627639
628640 /**
629641 * Outputs image to browser. Quality is in the range 0..100 for JPEG (default 85), WEBP (default 80) and AVIF (default 30) and 0..9 for PNG (default 9).
642+ * @param ImageType::* $type
630643 * @throws ImageException
631644 */
632645 public function send (int $ type = ImageType::JPEG , ?int $ quality = null ): void
@@ -639,6 +652,7 @@ public function send(int $type = ImageType::JPEG, ?int $quality = null): void
639652 /**
640653 * Outputs image to browser or file.
641654 * @throws ImageException
655+ * @param ImageType::* $type
642656 */
643657 private function output (int $ type , ?int $ quality , ?string $ file = null ): void
644658 {
0 commit comments