Skip to content

Commit

Permalink
adding URL helper function
Browse files Browse the repository at this point in the history
  • Loading branch information
dhrogers committed Nov 8, 2023
1 parent f0f626f commit 6f696d5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 7 additions & 0 deletions pycinema/Core.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ def shape(self):
def resolution(self):
return self.shape[:2][::-1]

def isURL(path):
s = path.strip()
if s.startswith("http") or s.startswith("HTTP"):
return True
else:
return False

def isNumber(s):
t = type(s)
if t == int or t == float:
Expand Down
4 changes: 2 additions & 2 deletions pycinema/filters/ImageReader.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from pycinema import Filter, Image
from pycinema import Filter, Image, isURL

import PIL
import numpy
Expand Down Expand Up @@ -73,7 +73,7 @@ def _update(self):
file.close()

elif str.lower(extension) in ['png','jpg','jpeg']:
if "https" in path:
if isURL(path):
rawImage = PIL.Image.open(requests.get(path, stream=True).raw)
else:
rawImage = PIL.Image.open(path)
Expand Down

0 comments on commit 6f696d5

Please sign in to comment.