谷歌镜像 伍佰目录 短网址
  当前位置:海洋目录网 » 站长资讯 » 站长资讯 » 文章详细 订阅RssFeed

PHP - Manual: Imagick::__construct

来源:网络转载 浏览:31202次 时间:2023-11-27
Imagick::contrastImage » « Imagick::compositeImage
  • PHP 手册
  • 函数参考
  • 图像生成和处理
  • ImageMagick
  • Imagick

Imagick::__construct

(PECL imagick 2, PECL imagick 3)

Imagick::__construct — The Imagick constructor

说明

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.

错误/异常

错误时抛出 ImagickException。

add a note

User Contributed Notes 4 notes

up down 10 martin at lks dot com10 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 down 8 andyearnshaw at do-not-spam-mygmail dot com9 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 down 2 divinity76 at gmail dot com3 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 down 3 Jerome8 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'));
?>
add a note

官方地址:https://www.php.net/manual/en/imagick.construct.php

  推荐站点

  • At-lib分类目录At-lib分类目录

    At-lib网站分类目录汇集全国所有高质量网站,是中国权威的中文网站分类目录,给站长提供免费网址目录提交收录和推荐最新最全的优秀网站大全是名站导航之家

    www.at-lib.cn
  • 中国链接目录中国链接目录

    中国链接目录简称链接目录,是收录优秀网站和淘宝网店的网站分类目录,为您提供优质的网址导航服务,也是网店进行收录推广,站长免费推广网站、加快百度收录、增加友情链接和网站外链的平台。

    www.cnlink.org
  • 35目录网35目录网

    35目录免费收录各类优秀网站,全力打造互动式网站目录,提供网站分类目录检索,关键字搜索功能。欢迎您向35目录推荐、提交优秀网站。

    www.35mulu.com
  • 就要爱网站目录就要爱网站目录

    就要爱网站目录,按主题和类别列出网站。所有提交的网站都经过人工审查,确保质量和无垃圾邮件的结果。

    www.912219.com
  • 伍佰目录伍佰目录

    伍佰网站目录免费收录各类优秀网站,全力打造互动式网站目录,提供网站分类目录检索,关键字搜索功能。欢迎您向伍佰目录推荐、提交优秀网站。

    www.wbwb.net