Reputation: 1616
How to set the image size to display? Running in VSCode Jupyter Interactive Window
from PIL import Image
from IPython.display import display
display(Image.open('imageURL'))
This code displays the Image as it is, i.e showing the original size,
Tried this, which works, but how to keep the ratio, image shrunks as it is
image = Image.open('imageURL')
image = image.resize((500,500),Image.ANTIALIAS)
display(image)
Upvotes: 8
Views: 15965
Reputation: 8803
If you are dealing with video, you can do the following:
from IPython.display import display, Video
display(Video(data=video_path, embed=True, width = 600, height = 300))
Note: It is not an answer to the image, but it is described as a reference.
Upvotes: 0
Reputation: 755
Try
from IPython.display import Image, display
display(Image('image.png', width=600))
You can also set a height
.
Upvotes: 10
Reputation: 674
Try this code
image = Image.open("imageURL")
scale = 0.3
display(image.resize(( int(image.width * scale), int(image.height * scale))))
Upvotes: 2