Jump to content

function to check images inside uploaded pdf for cmyk color mode


TecBrat

Recommended Posts

I have written a function, is_cmyk(); that can test jpeg and psd images, but I would like to add the ability to check for images contained in a pdf document. Does anyone know how to read this data using php?

 

I'll paste my existing code so you'll know the direction I am headed.

 

function is_cmyk($filename)
// currently ony works for jpg and psd. psd requires classPhpPsdReader.php by Tim de Koning
{
  $matches=split('\.',$filename);
    foreach ($matches as $key=>$value)
    {
      $extension=$value; //if there is more than one period, this will find the actual extension.
    }
  switch ($extension)
  {
    case 'psd':
      include('classPhpPsdReader.php');
      $psd = new PhpPsdReader($filename);
      if($psd->infoArray['colorMode']==4)
      {
       return TRUE;
      }
      break;
    case 'jpg':
    $size = getimagesize($filename);
    //echo ("get image size found $size[channels] channels");
    if($size[channels]==4)
    {
     return TRUE;
    }
    default:
    return FALSE;
    break;
  }
  return FALSE;
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.