谷歌镜像 伍佰目录 短网址
  当前位置:海洋目录网 » 站长资讯 » 站长资讯 » 文章详细 订阅RssFeed

PHP - Manual: Imagick::getImageProperties

来源:网络转载 浏览:30343次 时间:2024-03-09
Imagick::getImageProperty » « Imagick::getImageProfiles
  • PHP 手册
  • 函数参考
  • 图像生成和处理
  • ImageMagick
  • Imagick

Imagick::getImageProperties

(PECL imagick 2, PECL imagick 3)

Imagick::getImageProperties — Returns the image properties

说明

public Imagick::getImageProperties(string $pattern = "*", bool $include_values = true): array

Returns all associated properties that match the pattern. If false is passed as second parameter only the property names are returned. 此方法在Imagick基于ImageMagick 6.3.6以上版本编译时可用。

参数

pattern

The pattern for property names.

include_values

Whether to return only property names. If false then only property names will be returned.

返回值

Returns an array containing the image properties or property names.

范例

示例 #1 Using Imagick::getImageProperties():

An example of extracting EXIF information.

<?php

/* Create the object */
$im = new imagick("/path/to/example.jpg");

/* Get the EXIF information */
$exifArray = $im->getImageProperties("exif:*");

/* Loop trough the EXIF properties */
foreach ($exifArray as $name => $property)
{
    echo "{$name} => {$property}<br />\n"; 
}

?>
add a note

User Contributed Notes 4 notes

up down 0 benkuhl at gmail dot com9 years ago The output of this method on a PDF:

Array
        (
            [date:create] => 2013-01-24T13:27:37-05:00
            [date:modify] => 2013-01-24T13:27:37-05:00
            [pdf:HiResBoundingBox] => 1089x396+0+0
            [pdf:SpotColor-0] => PANTONE 697 C
            [pdf:SpotColor-1] => Black
            [pdf:SpotColor-10] => PANTONE 504 M C
            [pdf:SpotColor-2] => Strike_Thru
            [pdf:SpotColor-3] => PANTONE 7421 C
            [pdf:SpotColor-4] => PANTONE 697 C
            [pdf:SpotColor-5] => PANTONE 873 C
            [pdf:SpotColor-6] => PANTONE 504 M C
            [pdf:SpotColor-7] => Die
            [pdf:SpotColor-8] => PANTONE 697 C
            [pdf:SpotColor-9] => PANTONE 504 M C
            [pdf:Version] => PDF-1.5
            [signature] => 4d871b27b26537c523326f92454ecb2e19fa9e0e86e2a075f97354ad4f3bf122
        )
up down 0 holdoffhunger at gmail dot com10 years ago The getImageProperties function in PHP returns an array of property keys available for an image.  To get these property values, you use getImageProperty function, giving it one of the available keys provided by the getImageProperties function result.  For some images, you may have a lot of properties and for some, you may have few.  The two that almost every image seems to have are "date:create" and "date:modify", but some images may have forty or more properties, some titled "exif:Compression", "photoshop:Credit", "jpeg:colorspace", "rdf:Alt", "stRef:documentID", and "xap:CreatorTool."  PNG files will also have properties like "png:IHDR.bit_depth" and "png:IHDR.width,height."  So far, it appears generally that GIF and BMP files, being simpler, have fewer properties, whereas JPEG and PNG files, being more complicated, have much wider array of properties.  It seems incredibly useful in document management.

And now, some sample code and results :

<?php

            // Author: holdoffhunger@gmail.com
   
        // Imagick Type
        // ---------------------------------------------

    $imagick_type = new Imagick();
   
        // Open File
        // ---------------------------------------------
       
    $file_to_grab = "image_workshop_directory/test.png";
   
    $file_handle_for_viewing_image_file = fopen($file_to_grab, 'a+');
   
        // Grab File
        // ---------------------------------------------

    $imagick_type->readImageFile($file_handle_for_viewing_image_file);
   
        // Get Image Properties
        // ---------------------------------------------
       
    $imagick_type_properties = $imagick_type->getImageProperties('*', FALSE);
   
        // Print Image Properties
        // ---------------------------------------------
   
    print("<pre>");
       
    print_r($imagick_type_properties);
   
        // Print Each Individual, Image Property
        // ---------------------------------------------
   
    foreach($imagick_type_properties as $value)
    {
        print("$value --- ");
        print($imagick_type->getImageProperty("$value"));
        print("<br><br>");
    }
               
    print("</pre>");

?>

Results of this done on a standard PNG image :

Array
(
    [0] => date:create
    [1] => date:modify
    [2] => png:cHRM                
    [3] => png:gAMA                
    [4] => png:IHDR.bit_depth      
    [5] => png:IHDR.color_type     
    [6] => png:IHDR.interlace_method
    [7] => png:IHDR.width,height   
    [8] => png:sRGB                
)
date:create --- 2012-05-19T18:26:45-05:00

date:modify --- 2012-05-19T18:26:45-05:00

png:cHRM                  --- chunk was found (see Chromaticity, above)

png:gAMA                  --- gamma=0.45455 (See Gamma, above)

png:IHDR.bit_depth        --- 8

png:IHDR.color_type       --- 2

png:IHDR.interlace_method --- 0

png:IHDR.width,height     --- 320, 320

png:sRGB                  --- intent=0 (See Rendering intent)
up down 0 mhufford12 years ago ImageMagick only supports setting a very small number of EXIF properties. 

See http://www.imagemagick.org/discourse-server/viewtopic.php?t=14234
up down -1 www dot query at gmail dot com10 years ago To access a photograph's EXIF data an alternative method is the normal PHP Exif function.

<?php

        $exif_data = exif_read_data($pic1);
        $edate = $exif_data['DateTime'];

?>

See: http://php.net/manual/en/book.exif.php
add a note

官方地址:https://www.php.net/manual/en/imagick.getimageproperties.php

  推荐站点

  • At-lib分类目录At-lib分类目录

    At-lib网站分类目录汇集全国所有高质量网站,是中国权威的中文网站分类目录,给站长提供免费网址目录提交收录和推荐最新最全的优秀网站大全是名站导航之家

    www.at-lib.cn
  • 中国链接目录中国链接目录

    中国链接目录简称链接目录,是收录优秀网站和淘宝网店的网站分类目录,为您提供优质的网址导航服务,也是网店进行收录推广,站长免费推广网站、加快百度收录、增加友情链接和网站外链的平台。

    www.cnlink.org
  • 35目录网35目录网

    35目录免费收录各类优秀网站,全力打造互动式网站目录,提供网站分类目录检索,关键字搜索功能。欢迎您向35目录推荐、提交优秀网站。

    www.35mulu.com
  • 就要爱网站目录就要爱网站目录

    就要爱网站目录,按主题和类别列出网站。所有提交的网站都经过人工审查,确保质量和无垃圾邮件的结果。

    www.912219.com
  • 伍佰目录伍佰目录

    伍佰网站目录免费收录各类优秀网站,全力打造互动式网站目录,提供网站分类目录检索,关键字搜索功能。欢迎您向伍佰目录推荐、提交优秀网站。

    www.wbwb.net