Skip to content

Commit

Permalink
Image: used native PHP function for image types (#167)
Browse files Browse the repository at this point in the history
  • Loading branch information
holantomas authored and dg committed Apr 4, 2018
1 parent 695e45c commit 8bc32a1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Utils/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public static function fromFile(string $file, int &$detectedFormat = null)
$detectedFormat = null;
throw new UnknownImageFileException(is_file($file) ? "Unknown type of file '$file'." : "File '$file' not found.");
}
return new static(Callback::invokeSafe('imagecreatefrom' . self::$formats[$detectedFormat], [$file], function (string $message) {
return new static(Callback::invokeSafe('imagecreatefrom' . image_type_to_extension($detectedFormat, false), [$file], function (string $message) {
throw new ImageException($message);
}));
}
Expand Down Expand Up @@ -557,7 +557,7 @@ public function send(int $type = self::JPEG, int $quality = null): void
if (!isset(self::$formats[$type])) {
throw new Nette\InvalidArgumentException("Unsupported image type '$type'.");
}
header('Content-Type: image/' . self::$formats[$type]);
header('Content-Type: ' . image_type_to_mime_type($type));
$this->save(null, $quality, $type);
}

Expand Down

0 comments on commit 8bc32a1

Please sign in to comment.