How can I check jpg image for cmyk or rgb color mode in wordpress / php?

I just had a client upload a jpg image to CMYK, and it didn’t display correctly in IE and some versions of firefox. Is there a check I can do to make sure it is saved in RGB before loading it?

+3
source share
1 answer

You can use getimagesize(). http://php.net/manual/en/function.getimagesize.php

$imgDetails = getimagesize('yourimage.jpg');
if ($imgDetails['channels'] === 4) {
    // CMYK
} elseif ($imgDetails['channels'] === 3) {
    // RGB
}
+6
source

All Articles