downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | conferences | my php.net

search for in the

Imagick::contrastImage> <Imagick::compositeImage
[edit] Last updated: Fri, 17 May 2013

view this page in

Imagick::__construct

(PECL imagick 2.0.0)

Imagick::__constructThe Imagick constructor

Descrierea

Imagick::__construct ( mixed $files )

Creates an Imagick instance for a specified image or set of images.

Parametri

files

The path to an image to load or an array of paths. Paths can include wildcards for file names, or can be URLs.

Valorile întoarse

Returns a new Imagick object on success.

Erori/Excepții

Emite ImagickException în caz de eroare.



add a note add a note User Contributed Notes Imagick::__construct - [2 notes]
up
1
martin at lks dot com
11 months ago
If you are using windows imagemagick, at leat in my case, you have to include the full path of the file, including the 'c:' at the beginning. If you don't know for sure the way that the filename is going to come, you can use realpath() function to normalize it:

<?php
    $incoming_file
= '/Users/John/Desktop/file_loco.jpg';
   
$img = new Imagick(realpath($incoming_file));
   
// realpath() will convert '/Users/John/Desktop/file_loco.jpg' to 'C:\Users\John\Desktop\file_loco.jpg'
    // and ImageMagick will have no trouble when loading
?>
up
0
andyearnshaw at do-not-spam-mygmail dot com
2 months ago
If you try and load an ICO file whose extension isn't .ico, you'll get an error going along the lines of no delegate existing for the supplied image's format.  The can occur, for example, if you're using a temporary file.

<?php
$tmp
= tempnam('cache/images', 'ico_');

if (
copy('http://remote.url/favicon.ico', $tmp)) {
   
$ico = new Imagick($tmp);  // <-- ERROR!
}
?>

Your first thought might be to rename your temporary file's extension to .ico, but I decided to try something that works on the command line―prefix the file name with 'ico:'

<?php
$tmp
= tempnam('cache/images', 'ico_');

if (
copy('http://remote.url/favicon.ico', $tmp)) {
   
$ico = new Imagick("ico:$tmp");  // <-- Works great!
}
?>

 
show source | credits | sitemap | contact | advertising | mirror sites