检测图像是否已损坏或损坏 [英] Detecting whether an image is corrupted or broken
问题描述
我需要以编程方式检查用户在我的应用中选择的壁纸图像是否损坏或损坏.......
基本上我为用户提供了选择自己的图像的选项墙纸。现在当图像加载时,我只想检查它是否有点腐败.......
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 option to choose his own image as wallpaper. Now when the images loads, I just want to keep a check on whether it is somehow corrupt or not.......
推荐答案
如果您正在寻找PHP解决方案而不是javascript解决方案(潜在的重复项不提供),您可以使用GD的 getimagesize()并查看它返回的内容。当提供的图像格式无效时,它将返回false并抛出错误。
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.
这篇关于检测图像是否已损坏或损坏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!