-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fdc4cf4
commit d2a63f2
Showing
10 changed files
with
101 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import io | ||
|
||
# Rust import | ||
from .modern_colorthief import * | ||
|
||
__doc__ = modern_colorthief.__doc__ | ||
if hasattr(modern_colorthief, "__all__"): | ||
__all__ = modern_colorthief.__all__ | ||
|
||
|
||
def get_palette( | ||
image: str | bytes | io.BytesIO, | ||
color_count: int = 10, | ||
quality: int | None = 10, | ||
) -> list[tuple[int, int, int]]: | ||
if isinstance(image, str): | ||
return _get_palette_given_string(image, color_count, quality) | ||
|
||
if isinstance(image, bytes): | ||
return _get_palette_given_bytes(image, color_count, quality) | ||
|
||
if isinstance(image, io.BytesIO): | ||
return _get_palette_given_bytes(image.getvalue(), color_count, quality) | ||
|
||
|
||
def get_color( | ||
image: str | bytes | io.BytesIO, | ||
quality: int | None = 10, | ||
) -> tuple[int, int, int]: | ||
if isinstance(image, str): | ||
return _get_color_given_location(image, quality) | ||
|
||
if isinstance(image, bytes): | ||
return _get_color_given_bytes(image, quality) | ||
|
||
if isinstance(image, io.BytesIO): | ||
return _get_color_given_bytes(image.getvalue(), quality) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,16 @@ | ||
import io | ||
from PIL import Image | ||
|
||
img = Image.open('test.jpg', mode='r') | ||
img = Image.open("test.jpg", mode="r") | ||
|
||
img_byte_arr = io.BytesIO() | ||
img.save(img_byte_arr, format='PNG') | ||
img_byte_arr = img_byte_arr.getvalue() | ||
img.save(img_byte_arr, format="PNG") | ||
# img_byte_arr = img_byte_arr.getvalue() | ||
|
||
print(img_byte_arr) | ||
|
||
import modern_colorthief | ||
|
||
|
||
x = modern_colorthief.get_color(img_byte_arr) | ||
|
||
print(isinstance(img_byte_arr, io.BytesIO)) |