Skip to content

Commit

Permalink
Merge pull request #2780 from timber/2771-bug-towebp-causes-uncaught-…
Browse files Browse the repository at this point in the history
…typeerror-imageistruecolor-argument-1-$image-must-be-of-type-gdimage-null-given-error
  • Loading branch information
gchtr authored Jul 31, 2023
2 parents 7b1dd06 + cb9243f commit f56f062
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Image/Operation/ToJpg.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ public function run($load_filename, $save_filename)

$input = $imagecreate_function($load_filename);

if ($input === false) {
return false;
}

list($width, $height) = \getimagesize($load_filename);
$output = \imagecreatetruecolor($width, $height);
$c = self::hexrgb($this->color);
Expand Down
4 changes: 4 additions & 0 deletions src/Image/Operation/ToWebp.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ public function run($load_filename, $save_filename)

$input = $imagecreate_function($load_filename);

if ($input === false) {
return false;
}

if (!\imageistruecolor($input)) {
\imagepalettetotruecolor($input);
}
Expand Down

0 comments on commit f56f062

Please sign in to comment.