Detect if image is grayscale or color using Imagick
问题 I'm attempting to try and assign a value to an image based on its 'saturation level', to see if the image is black and white or color. I'm using Imagick, and have found what seems to be the perfect code for the command line and am trying to replicate it using the PHP library. I think I understand the concept: Convert image to HSL. Extract the 'g' channel (which is the S channel in HSL). Calculate the mean of this channel. Command line code convert '$image_path' -colorspace HSL -channel g