Add replace_color.
This commit is contained in:
parent
797b4efd89
commit
c1cba4f287
1 changed files with 9 additions and 0 deletions
|
@ -73,6 +73,15 @@ def pad_to_square(image, background_color=None) -> PIL.Image:
|
||||||
new_image.paste(image, (diff_w, diff_h))
|
new_image.paste(image, (diff_w, diff_h))
|
||||||
return new_image
|
return new_image
|
||||||
|
|
||||||
|
def replace_color(image, from_color, to_color):
|
||||||
|
image = image.copy()
|
||||||
|
pixels = image.load()
|
||||||
|
for y in range(image.size[1]):
|
||||||
|
for x in range(image.size[0]):
|
||||||
|
if pixels[x, y] == from_color:
|
||||||
|
pixels[x, y] = to_color
|
||||||
|
return image
|
||||||
|
|
||||||
def rotate_by_exif(image):
|
def rotate_by_exif(image):
|
||||||
'''
|
'''
|
||||||
Rotate the image according to its exif data, so that it will display
|
Rotate the image according to its exif data, so that it will display
|
||||||
|
|
Loading…
Reference in a new issue