Skip to content

Commit 8bc32a1

Browse files
holantomasdg
authored andcommitted
Image: used native PHP function for image types (#167)
1 parent 695e45c commit 8bc32a1

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/Utils/Image.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ public static function fromFile(string $file, int &$detectedFormat = null)
152152
$detectedFormat = null;
153153
throw new UnknownImageFileException(is_file($file) ? "Unknown type of file '$file'." : "File '$file' not found.");
154154
}
155-
return new static(Callback::invokeSafe('imagecreatefrom' . self::$formats[$detectedFormat], [$file], function (string $message) {
155+
return new static(Callback::invokeSafe('imagecreatefrom' . image_type_to_extension($detectedFormat, false), [$file], function (string $message) {
156156
throw new ImageException($message);
157157
}));
158158
}
@@ -557,7 +557,7 @@ public function send(int $type = self::JPEG, int $quality = null): void
557557
if (!isset(self::$formats[$type])) {
558558
throw new Nette\InvalidArgumentException("Unsupported image type '$type'.");
559559
}
560-
header('Content-Type: image/' . self::$formats[$type]);
560+
header('Content-Type: ' . image_type_to_mime_type($type));
561561
$this->save(null, $quality, $type);
562562
}
563563

0 commit comments

Comments
 (0)