PHP.mk документација

Imagick::__construct

Почист и полокален преглед на PHP референцата, со задржана структура од PHP.net и подобра читливост за примери, секции и белешки.

imagick.construct.php PHP.net прокси Преводот се освежува
Оригинал на PHP.net
Патека imagick.construct.php Локална патека за оваа страница.
Извор php.net/manual/en Оригиналниот HTML се реупотребува и локално се стилизира.
Режим Прокси + превод во позадина Кодовите, табелите и белешките остануваат читливи во истиот тек.
Imagick::__construct

Референца за `imagick.construct.php` со подобрена типографија и навигација.

imagick.construct.php

Imagick::__construct

(PECL imagick 2, PECL imagick 3)

Imagick::__constructThe Imagick constructor

= NULL

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

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

Параметри

files

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

Errors/Exceptions

Фрла ImagickException при грешка.

Белешки од корисници 4 белешки

martin at lks dot com
пред 13 години
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
?>
andyearnshaw at do-not-spam-mygmail dot com
пред 13 години
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!
}
?>
[email protected]
пред 6 години
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()
Jerome
12 години пред
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'));
?>
Навигација

Прелистувај сродни теми и функции.

На оваа страница

Автоматски outline од активната документација.

Насловите ќе се појават тука по вчитување.

Попрегледно читање

Примерите, changelog табелите и user notes се визуелно издвоени за да не се губат во долгата содржина.

Брз совет Користи го outline-от Скокни директно на главните секции од активната страница.
Извор Оригиналниот линк останува достапен Кога ти треба целосен upstream context, отвори го PHP.net во нов tab.