Imagick::getImageProperties

(PECL imagick 2.0.0)

Imagick::getImagePropertiesReturns the image properties

Описание

array Imagick::getImageProperties ([ string $pattern = "*" [, bool $only_names = true ]] )

Returns all associated properties that match the pattern. If TRUE is passed as second parameter only the property names are returned. Этот метод доступен, если Imagick был скомпилирован с версией ImageMagick 6.3.6 или старше.

Список параметров

pattern

The pattern for property names.

only_names

Whether to return only property names. If FALSE then also the values are 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"
}

?>

Коментарии

Автор:
ImageMagick only supports setting a very small number of EXIF properties. 

See http://www.imagemagick.org/discourse-server/viewtopic.php?t=14234
2009-08-03 17:03:55
http://php5.kiev.ua/manual/ru/imagick.getimageproperties.html
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: book.exif
2011-09-08 14:58:37
http://php5.kiev.ua/manual/ru/imagick.getimageproperties.html
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)
2012-05-20 02:29:07
http://php5.kiev.ua/manual/ru/imagick.getimageproperties.html
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
        )
2013-01-24 20:40:26
http://php5.kiev.ua/manual/ru/imagick.getimageproperties.html

    Поддержать сайт на родительском проекте КГБ