duanhongqiong9460 2011-10-24 09:28
浏览 286
已采纳

如何在PHP中识别CMYK图像

Can anyone tell me how to identify an image if it is in CMYK or RGB using PHP ?

  • 写回答

5条回答 默认 最新

  • douhu3424 2011-10-24 09:40
    关注

    Take a good look at getimagesize.

    Example:

    <?php
    $size = getimagesize($filename);
    $fp = fopen($filename, "rb");
    if ($size && $fp) {
        header("Content-type: {$size['mime']}");
        fpassthru($fp);
        exit;
    } else {
        // error
    }
    ?>
    

    It returns an array with 7 elements.

    Index 0 and 1 contains respectively the width and the height of the image.

    Index 2 is one of the IMAGETYPE_XXX constants indicating the type of the image.

    Index 3 is a text string with the correct height="yyy" width="xxx" string that can be used directly in an IMG tag.

    mime is the correspondant MIME type of the image. This information can be used to deliver images with the correct HTTP Content-type header: channels will be 3 for RGB pictures and 4 for CMYK pictures.

    bits is the number of bits for each color.

    For some image types, the presence of channels and bits values can be a bit confusing. As an example, GIF always uses 3 channels per pixel, but the number of bits per pixel cannot be calculated for an animated GIF with a global color table.

    On failure, FALSE is returned.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效