Skip to content

Commit

Permalink
default remotely downloaded images to be converted to a flat rgb colo…
Browse files Browse the repository at this point in the history
…urspace to be compatible with jpeg encoding, resolves #504
  • Loading branch information
meeb committed Jun 11, 2024
1 parent 7ad54c1 commit e3b5d63
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions tubesync/sync/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,17 @@ def validate_url(url, validator):
return extract_value


def get_remote_image(url):
def get_remote_image(url, force_rgb=True):
headers = {
'user-agent': ('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 '
'(KHTML, like Gecko) Chrome/69.0.3497.64 Safari/537.36')
}
r = requests.get(url, headers=headers, stream=True, timeout=60)
r.raw.decode_content = True
return Image.open(r.raw)
i = Image.open(r.raw)
if force_rgb:
i = i.convert('RGB')
return i


def resize_image_to_height(image, width, height):
Expand Down

0 comments on commit e3b5d63

Please sign in to comment.