IMagick is a native PHP extension to create and modify images using the ImageMagick API. ImageMagick Studio LLC did not write nor does it maintain the IMagick extension, however, IMagick users are welcome to discuss the extension here.
linjuming
Posts: 122 Joined: 2011-01-25T00:09:50-07:00
Authentication code: 8675308
Contact:
Post
by linjuming » 2011-03-19T20:05:30-07:00
Code: Select all
<?php
$width = 100;
$height = 200;
$im=new Imagick();
$im->newimage($width,$height,"red");
$im->writeimage("img/selected_overlay/selected_overlay.gif");
?>
error info:
Catchable fatal error: Argument 3 passed to Imagick::newimage()
must be an instance of ImagickPixel , string given in D:\phpnow\htdocs\mycenter\oocss\create_selected_overlay.php on line 7
old version is ok ,but error occurs in the lastest version .how to fix?
fmw42
Posts: 25562 Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA
Contact:
Post
by fmw42 » 2011-03-19T20:12:13-07:00
linjuming
Posts: 122 Joined: 2011-01-25T00:09:50-07:00
Authentication code: 8675308
Contact:
Post
by linjuming » 2011-03-19T20:20:14-07:00
Code: Select all
<?php
@$width = $_POST["width"];
@$height = $_POST["height"];
$width = 100;
$height = 200;
$im=new Imagick();
$color=new imagickpixel("rgb(0,0,0,0)");
$im->newimage($width,$height,$color);
$im->setimageformat("png32");
// header( "Content-Type: image/gif" );
// echo $im;
$im->writeimage("img/selected_overlay/selected_overlay.png");
?>
why is the created png black ? my imagick version is the latest now .
fmw42
Posts: 25562 Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA
Contact:
Post
by fmw42 » 2011-03-19T20:23:00-07:00
you did not pay attention to the example I reference above. Here it is:
<?php
$image = new Imagick();
$image->newImage(100, 100, new ImagickPixel('red') );
$image->setImageFormat('png');
header('Content-type: image/png');
echo $image;
?>
linjuming
Posts: 122 Joined: 2011-01-25T00:09:50-07:00
Authentication code: 8675308
Contact:
Post
by linjuming » 2011-03-19T20:25:06-07:00
i want to get a completely transparent png ,not red , i am sorry i did not modify the color name before.
tried "none" and "transparent" ,the result is black as the same.
fmw42
Posts: 25562 Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA
Contact:
Post
by fmw42 » 2011-03-19T21:02:37-07:00
try enabling the alpha channel first, see
http://us3.php.net/manual/en/function.i ... hannel.php
or better
replace
$color=new imagickpixel("rgb(0,0,0,0)");
with
$color=new imagickpixel("rgb
a (0,0,0,0)");
linjuming
Posts: 122 Joined: 2011-01-25T00:09:50-07:00
Authentication code: 8675308
Contact:
Post
by linjuming » 2011-03-19T21:12:02-07:00
thank you ! all is ok.
fmw42
Posts: 25562 Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA
Contact:
Post
by fmw42 » 2011-03-19T21:38:22-07:00
glad that helped. it is a common mistake that even I have done from time to time.
Users browsing this forum: No registered users and 15 guests