脚本宝典收集整理的这篇文章主要介绍了使用PHP或Imagick获取图像ICC配置文件,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在将图像上传到网站&想提取每个图像的名称ICC PRofile&在图像描述中使用它.到目前为止,标准PHP没有产生任何结果.我用Photoshop,bridge& amp;检查了图像. Exiftool&每个人都已确定嵌入的个人资料
<?PHP $info = exif_read_data($image); echo 'ICC Profile: '.$info['ICC_Profile'].'<br>'; echo 'ICC Profile: '.$info['currentICCProfile'].'<br>'; echo 'ICC Profile: '.$info['ColorSpace'].'<br>'; ?>
Imagick产生了最好的结果:
$imagick = new Imagick(); $imagick->readImage($image); print_r ($imagick->getImageProfiles("icc",true));
我正在使用这些版本:
print_r返回(对于’ProPhoto RGB’ICC配置文件):
全部(来自Exiftool):
Profile CMM TyPE : KCMS Profile Version : 2.1.0 Profile Class : Display Device Profile Color Space Data : RGB Profile Connection Space : XYZ Profile Date Time : 1998:12:01 18:58:21 Profile File Signature : acsp Primary Platform : Microsoft Corporation CMM Flags : Not Embedded,Independent Device Manufacturer : KODA Device Model : romM Device Attributes : Reflective,Glossy,PosITive,Color Rendering Intent : Perceptual Connection Space Illuminant : 0.9642 1 0.82487 Profile Creator : KODA Profile ID : 0 Profile Copyright : Copyright (c) Eastman Kodak Company,all rights reserved. Profile Description : ProPhoto RGB Media White Point : 0.9642 1 0.82489 red Tone Reproduction Curve : (Binary data 14 bytes,use -b option to extract) Green Tone Reproduction Curve : (Binary data 14 bytes,use -b option to extract) Blue Tone Reproduction Curve : (Binary data 14 bytes,use -b option to extract) Red Matrix Column : 0.79767 0.28804 0 Green Matrix Column : 0.13519 0.71188 0 Blue Matrix Column : 0.03134 9e-005 0.82491 Device Mfg Desc : KODAK Device Model Desc : Reference Output Medium Metric(ROMM) Make And Model : (Binary data 40 bytes,use -b option to extract)
$imagick = new imagick('/some/filename'); $profile = $imagick->getImageProperties('icc:model',true); /** * If the property 'icc:model' is set $profile Now should be: * array( 'icc:model' => 'ICC model name') */
如果要查看为图像设置的所有属性,可以使用identify -verbose / some / filename手动探测图像.在那里你将不得不寻找“属性:”,ICC名称应该在那里设置.
以上是获取ICC配置文件名称的简便方法.如果您确实需要icc配置文件中的ICC名称,您可能需要查看ICC Profile Format Specification
简而言之:
>前128个字节是标题.然后是一个标记表,其中前4个字节是表的大小.
>每个标签由4个字节的三元组组成.前4个字节是标签的名称.接下来的四个字节是icc文件中数据的偏移量.接下来的四个字节定义标签数据的大小.
我们对’desc’标签感兴趣(参见规范中的第63页).
>描述本身再次以’desc’开始,然后保留四个字节.接下来的四个字节定义ICC配置文件名称的大小.
在代码中它的工作方式如下:
$image = new imagick('/path/to/img'); try { $existingICC = $image->getImageProfile('icc'); } catch (ImagickException $e) { // Handle it $existingICC = null; } if($existingICC) { // SeArch the start of the description tag in the tag table.: // We are not looking in the 128 bytes for the header + 4 bytes for the size of the table $descTagPos = strIPOs( $existingICC,'desc',131 ); if( $descTagPos === false) { // There is no description,handle it. } else { // This is the description Tag ( 'desc'|offset|size each with a size of 4 bytes $descTag = substr( $existingICC,$descTagPos,12 ); // Get the offset out of the description tag,unpack it From binary to hex and then from hex to decimal $descTagOffset = substr ( $descTag,4,4 ); $descTagOffset = unpack( 'H*',$descTagOffset ); $descTagOffset = hexdec( $descTagOffset[1] ); // Same for the description size $descTagSize = substr ( $existingICC,$descTagPos + 8,4 ); $descTagSize = unpack('H*',$descTagSize); $descTagSize = hexdec( $descTagSize[1] ); // Here finally is the descripton $iccDesc = substr( $existingICC,$descTagOffset,$descTagSize ); // See page 63 in the standard,here we extract the size of the ICC profile name string $iccnamesize = substr( $iccDesc,8,4 ); $iccNameSize = unpack( 'H*',$iccNameSize); $iccNameSize = hexdec( $iccNameSize[1]); // Finally got the name. $iccName = substr( $iccDesc,12,$iccNameSize ); echo "ICC name: $iccName\n"; } }
以上是脚本宝典为你收集整理的使用PHP或Imagick获取图像ICC配置文件全部内容,希望文章能够帮你解决使用PHP或Imagick获取图像ICC配置文件所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。