Online-Image-Size

Sun 29 June 2025
from PIL import Image
import numpy as np
import urllib.request
image_path = 'https://multimedia.bbycastatic.ca/multimedia/products/500x500/107/10736/10736343.jpg'
with urllib.request.urlopen(image_path) as url:
    with open('temp.jpg', 'wb') as f:
        f.write(url.read())

img = Image.open('temp.jpg')
img

png

print(img)
<PIL.JpegImagePlugin.JpegImageFile image mode=RGB size=500x500 at 0x1315A029850>
image_array = np.asarray(Image.open('temp.jpg'))
image_array.shape
(500, 500, 3)


Score: 5

Category: basics