Skip to content

Commit

Permalink
Merge pull request #59 from gdarko/master
Browse files Browse the repository at this point in the history
Added fromContents method to Palette
  • Loading branch information
colinodell authored Sep 24, 2022
2 parents 3009704 + c039546 commit 3c6e46c
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/Palette.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,20 @@ public static function fromFilename($filename, $backgroundColor = null)
if (!is_readable($filename)) {
throw new \InvalidArgumentException('Filename must be a valid path and should be readable');
}
$image = imagecreatefromstring(file_get_contents($filename));

return self::fromContents(file_get_contents($filename), $backgroundColor);
}

/**
* Create instance with file contents
*
* @param string $contents
* @param int|null $backgroundColor
*
* @return Palette
*/
public static function fromContents($contents, $backgroundColor = null) {
$image = imagecreatefromstring($contents);
$palette = self::fromGD($image, $backgroundColor);
imagedestroy($image);

Expand Down

0 comments on commit 3c6e46c

Please sign in to comment.