How can one determine whether a JPEG image is in RGB or CMYK color mode?

To determine whether a JPEG image is in RGB or CMYK color mode, you can use PHP's `exif_imagetype()` function to check the color space information stored in the image metadata. If the image is in RGB color mode, the function will return `IMAGETYPE_JPEG`, while if the image is in CMYK color mode, it will return `IMAGETYPE_TIFF_II` or `IMAGETYPE_TIFF_MM`.

$image_path = 'image.jpg';
$image_type = exif_imagetype($image_path);

if($image_type === IMAGETYPE_JPEG) {
    echo 'Image is in RGB color mode';
} elseif($image_type === IMAGETYPE_TIFF_II || $image_type === IMAGETYPE_TIFF_MM) {
    echo 'Image is in CMYK color mode';
} else {
    echo 'Unable to determine color mode';
}