Skip to content
Advertisement

I can’t check broken images from a url

I am trying from a basic code from python to be able to verify the images that are broken, but I do not know how to do it

this is the code i am using:

JavaScript

Can someone help me!

Thank you very much!

Advertisement

Answer

There are a couple of things that needs to be done to verify if a file from web is an image or not.

  1. PIL.Image method accepts a file object or a string for local file, whereas you are trying to provide a web link. [You can download the file, save it locally and then open it.]
  2. You need to catch the exception, if there is any, and then display if the file is bad or not.

I have added the basic code below.

JavaScript

OUTPUT :

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement