zoukankan      html  css  js  c++  java
  • 声色贴生成图片总结 Imagick

    2014-08-24
    都是按以前的程序进行了,但去年8月都可以用Imagick正常生成CMYK的图片,但今天就是不行。
    经过一切测试方法及思路,解决方法如下。

    问题主要出现在: 生成的二维码是RGB格式,需要转换为CMYK,然后在与CMYK的模块进行图片合成。


    第一: 以前生成的二维码是png格式,位深度为8。经过分析将生成的二维码改为jpg格式,位深度为24.

    第二:在与模板合成之前,将二维码转换为CMYK格式。然后在与模板合并。

        private function RGBtoCMYK($source, $save_file, $icc_cmyk, $icc_rgb){
                $img_object = new Imagick($source);
                if ($img_object->getImageColorspace() == 1 OR $img_object->getImageColorspace() == 13) { 
                   $profiles = $img_object->getImageProfiles('*', false); 
                   $has_icc_profile = (array_search('icc', $profiles) !== false); 
                   if ($has_icc_profile === false) { 
                           //$icc_cmyk = file_get_contents('./Public/Img/AdobeRGB1998.icc'); 
                           $img_object->profileImage('icc', $icc_cmyk); 
                           unset($icc_cmyk); 
                   } 
                   //$icc_rgb = file_get_contents('./Public/Img/USWebUncoated.icc');                             
                   $img_object->profileImage('icc', $icc_rgb); 
                   unset($icc_rgb);    
                } 
                $image_data = $img_object->getImageGeometry(); 
                $img_object->setImageColorspace(12); 
                $img_object->setImageFormat('jpeg'); 
    
                $img_object->writeImage($save_file); 
                $img_object->clear(); 
                $img_object->destroy();
                return $save_file;
        }    
    

      

  • 相关阅读:
    【转载】Chrome 0day漏洞:不要用Chrome查看pdf文件
    内网渗透闲谈
    Sticky Fingure安装教程
    局域网下交换机配置
    Access 2010 应用基础 单元三:SQL查询
    ESP8266 wifi干扰、钓鱼实现
    这是谁的锅
    svn/git的diff、patch
    sublime开发php必备工具集合(mac)
    gcc学习笔记
  • 原文地址:https://www.cnblogs.com/xiangxiaodong/p/3932811.html
Copyright © 2011-2022 走看看