Detecting whether an image is corrupted or broken

前端 未结 3 2113
有刺的猬
有刺的猬 2021-01-19 07:10

I need to programmatically check whether the image that the user has selected as his wallpaper on my app is broken or corrupted....... basically I provide user with the opt

3条回答
  •  天命终不由人
    2021-01-19 08:00

    If instead you are looking for a PHP solution instead of a javascript solution (which the potential duplicates do not provide), you can use GD's getimagesize() in PHP and see what it returns. It will return false and throw an error when the provided image format is not valid.

提交回复
热议问题