How to distinguish black and white photo using PHP

  1. Assume that we are uploading a photo and we want to tell if it's a color image or black and white.
    One way to find this out for JPEG and TIFF files is to use exif data of the photo.
  2. Let $file be the variable that contains the path to the image file on the server. Then the line $exif = exif_read_data($file); will create an array $exif where exif data is stored.
  3. If exists, array element $exif['COMPUTED']['IsColor'] contains data about the photo's color depth.
    $exif['COMPUTED']['IsColor'] == 1 - photo is a color image
    $exif['COMPUTED']['IsColor'] == 0 - photo is black and white
Этот сервис - коллекция руководств и инструкций по самым разным темам
 
Зарегистрировавшись, вы сможете писать свои руководства.
Зарегистрироваться
 
Погружаемся
 

 
О руководстве
 
Автор: shredder_y
Тэги:
Рейтинг:
3