Imagick::__construct

(PECL imagick 2, PECL imagick 3)

Imagick::__construct β€” ΠšΠΎΠ½ΡΡ‚Ρ€ΡƒΠΊΡ‚ΠΎΡ€ ΠΎΠ±ΡŠΠ΅ΠΊΡ‚Π° Imagick

ОписаниС

public function Imagick::__construct(mixed $files = ?)

Π‘ΠΎΠ·Π΄Π°Ρ‘Ρ‚ экзСмпляр Imagick для ΠΎΡ‚Π΄Π΅Π»ΡŒΠ½ΠΎΠ³ΠΎ изобраТСния ΠΈΠ»ΠΈ Π³Ρ€ΡƒΠΏΠΏΡ‹ ΠΈΠ·ΠΎΠ±Ρ€Π°ΠΆΠ΅Π½ΠΈΠΉ.

Бписок ΠΏΠ°Ρ€Π°ΠΌΠ΅Ρ‚Ρ€ΠΎΠ²

files

ΠŸΡƒΡ‚ΡŒ ΠΊ ΠΈΠ·ΠΎΠ±Ρ€Π°ΠΆΠ΅Π½ΠΈΡŽ для Π·Π°Π³Ρ€ΡƒΠ·ΠΊΠΈ ΠΈΠ»ΠΈ массив Ρ‚Π°ΠΊΠΈΡ… ΠΏΡƒΡ‚Π΅ΠΉ. ΠŸΡƒΡ‚ΠΈ ΠΌΠΎΠ³ΡƒΡ‚ ΡΠΎΠ΄Π΅Ρ€ΠΆΠ°Ρ‚ΡŒ Π³Ρ€ΡƒΠΏΠΏΠΎΠ²Ρ‹Π΅ символы для ΠΈΠΌΡ‘Π½ Ρ„Π°ΠΉΠ»ΠΎΠ² ΠΈΠ»ΠΈ ΠΌΠΎΠ³ΡƒΡ‚ ΡΠ²Π»ΡΡ‚ΡŒΡΡ URL.

Ошибки

Ѐункция выбрасываСт ΠΈΡΠΊΠ»ΡŽΡ‡Π΅Π½ΠΈΠ΅ ImagickException, Ссли Π²ΠΎΠ·Π½ΠΈΠΊΠ»Π° ошибка.

οΌ‹Π”ΠΎΠ±Π°Π²ΠΈΡ‚ΡŒ

ΠŸΡ€ΠΈΠΌΠ΅Ρ‡Π°Π½ΠΈΡ ΠΏΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚Π΅Π»Π΅ΠΉ 4 notes

up
9
martin at lks dot com ΒΆ
14 years 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
6
andyearnshaw at do-not-spam-mygmail dot com ΒΆ
13 years 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!
}
?>
up
3
divinity76 at gmail dot com ΒΆ
7 years ago
if you need to create an image from a string containing the image binary, use readImageBlob, eg

<?php
$imagick = new Imagick();
$imagick->readImageBlob($str);
?>

likewise if you need to create an image from a file handle (without having the filepath), use readImageFile()
up
1
Jerome ΒΆ
12 years ago
you can use PDF page as image. To do that, install ghostscript libraries.
IMagick use ghostscript to read PDF page.

<?php
$myurl = '/pdf/mypdf.pdf';
$image = new Imagick(realpath($myurl).'[0]'); //[0] indicate the number of the wanted page
$image->setResolution( 300, 300 );
$image->setImageFormat( "png" );
$image->writeImage(realpath('./mypdf.png'));
?>