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;
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.