PHP: Determine Visually Corrupted Images (yet valid) downloaded via Curl with GD/Imagemagick

前端 未结 4 601
执念已碎
执念已碎 2020-12-10 07:54

I\'m using Curl via Proxies to download images with a scraper I have developed.

Unfortunately, it gets the odd image which looks like these and the last one is compl

4条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-10 08:28

    If the image it is returning is a valid file, then I would recommend running the scrape twice (ie. download it twice and check to see if they are the same).

    Another option would be to check the last few pixels of the image (ie. bottom-right corner) to see if they match that color of grey exactly. If they do, then redownload. (obviously this approach fails if you download an image that is actually supposed to be grey in that corner, in that exact colour...but if you check several of the last pixels it should reduce the chance of that to an acceptable level).

提交回复
热议问题