Spaces:
Sleeping
Sleeping
File size: 469 Bytes
01cd72e | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | 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
|