Imagick::polaroidImage

(PECL imagick 2.0.0)

Imagick::polaroidImageSimulates a Polaroid picture

Описание

bool Imagick::polaroidImage ( ImagickDraw $properties , float $angle )

Simulates a Polaroid picture. Этот метод доступен, если Imagick был скомпилирован с версией ImageMagick 6.3.2 или старше.

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

properties

The polaroid properties

angle

The polaroid angle

Возвращаемые значения

В случае успешной работы возвращает TRUE.

Примеры

Пример #1 A Imagick::polaroidImage() example

An example of using Imagick::polaroidImage()

<?php
/* Create the object */
$image = new Imagick('source.png');

/* Set the opacity */
$image->polaroidImage(new ImagickDraw(), 25);

/* output the image */
header('Content-type: image/png');
echo 
$image;

?>

Коментарии

At first, the polaroidImage function looked amazingly simple.  "It must simply give a border of a specified color, and then rotate the given image by a certain number of degrees."  It actually turns out to be a really neat function.  Not only does it create an image that looks like a Polaroid of the targetted file, but it gives it a slight bend and curl that simulates a real, physical photograph.  On top of that, it gives a minor, fuzz shadow to some of the borders that accentuate the entire "effect" of looking at a real, 3d photograph.  There are some essentials to know, though!

The first parameter, $properties, has absolutely no effect upon the image that I can tell.  I suspect that this is a miswrite, and what is implied is that you need to edit the properties of the Imagick class object that you're doing the PolaroidImage to.  There are two colors: the border of the image, and the color of shadow.  Both are set with the setImageBorderColor and setImageBackgroundColor functions, conveniently.  Unfortunately, this function still seems to demand a blank value for "properties", and NULL doesn't do it apparently.

One final note of precaution: the color of the surface that the photograph lies on defaults to black for BMP files, and then to white to PNG files. (Weird, huh?)  Others have noticed this as well, on what appears to be the best source of info on this function: http://valokuva.org/?p=37 .

The angle rotates clockwise.  If you want to rotate counter-clockwise, it's easy: just use negative numbers, which this function accepts.

Now, for a brief demonstration of this function, with some fairly decent, standard parameters that should fit anyone's needs:

<?php

           
// Author: holdoffhunger@gmail.com

        // Grab Image File Data
        // ---------------------------------------------

   
$file_to_grab_with_location "image_workshop_directory/test.png"
   
       
// Create ImageMagick Object Types
        // ---------------------------------------------

   
$imagick_type = new Imagick();
   
$draw_type = new ImagickDraw();
   
       
// Open File
        // ---------------------------------------------
   
   
$file_handle_for_viewing_image_file fopen($file_to_grab_with_location'a+');

   
$imagick_type->readImageFile($file_handle_for_viewing_image_file);

       
// Perform Function: PolaroidImage
        // ---------------------------------------------

            // Polaroid Border Color:
            // ..............................................
   
   
$imagick_type->setImageBorderColor( new ImagickPixel"$inbound_polaroid_border_color" ) );

           
// Polaroid Shadow Color:
            // ..............................................

   
$imagick_type->setImageBackgroundColor( new ImagickPixel"$inbound_polaroid_background_color" ) );

           
// Call Function:
            // ..............................................

   
$imagick_type->polaroidImage($draw_type, -10);
   
       
// Save File
        // ---------------------------------------------
       
   
$file_to_save_with_location "image_workshop_directory/test_result.png"

   
$file_handle_for_saving_image_file fopen($file_to_save_with_location'a+');
   
$imagick_type->writeImageFile($file_handle_for_saving_image_file);

?>
2012-04-29 02:39:19
http://php5.kiev.ua/manual/ru/imagick.polaroidimage.html

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