rodolphethinks1's picture
Update src/utils/image.py
26bf8af verified
raw
history blame contribute delete
469 Bytes
import re
import os
from io import BytesIO
from PIL import Image
def extract_url_after_filename(url):
"""Extract the filename from the URL."""
match = re.search(r'\?filename=(.*)', url)
return match.group(1) if match else None
def convert_jp2_to_image(content):
"""Convert JP2 image content to PIL Image."""
try:
return Image.open(BytesIO(content))
except Exception as e:
print(f"Error opening image: {e}")
return None