Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check image corrupt or not in php? [duplicate]

Tags:

php

How to check image corrupt or not using url in php.Is it possible to check in php? I need to check using image url check image corrupt or not.

like image 215
Geetha Janarthanan Avatar asked Nov 27 '25 05:11

Geetha Janarthanan


1 Answers

Use getimagesize() it will return FALSE if file corrupt otherwise if file is ok then it will return array containing file info like mime, height and width etc, try below example

<?php
  $fileName = 'image/corruptsample.jpg'; //filepath
  if(getimagesize($fileName) === false){
    echo "file is corrupted";
  }
  else{
    echo "file is ok";
  }
like image 135
Vishal Solanki Avatar answered Nov 28 '25 20:11

Vishal Solanki



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!