Reputation: 1305
I am trying to convert and image to a tiff using imagemagick but am running into a problem when trying to write the file. I get an error that says:
Unable to open image... error/blob.c/OpenBlob/2584'
This is the code I am using:
$im2 = new Imagick($image);
$im2->setImageFormat("tiff");
$im2->setImageColorSpace(5);
$im2->writeImage("test.tiff");
$image is just a url I am passing to an image file. I am just running a simple test function to get it to work and put a test.tiff in the same folder. What could I be doing wrong here? Having trouble finding much documentation on this.
Upvotes: 2
Views: 6542
Reputation: 21
Imagick works with local files and remote files.
$im2 = new Imagick($image);
$im2->setImageFormat("tiff");
$im2->setImageColorSpace(5);
$im2->writeImage("test.tiff");
It would work equally well in both remote and local server. The pfunc already said is permissions error. Another case that this error occurs is the definition of the directory incorrectly. sorry my en
Upvotes: 2
Reputation: 4688
The argument of the Imagick
constructor is to load a local image file. To load a remote image file, you should instantiate an Imagick
object without arguments and either:
readImageBlob
method, orfopen
the URL and pass it to the readImageFile
method.For example:
// assuming $image is an URL or path to a local file
$handle = fopen($image, 'rb');
$im2 = new Imagick();
$im2->readImageFile($handle);
$im2->setImageFormat("tiff");
$im2->setImageColorSpace(5);
$im2->writeImage("test.tiff");
fclose($handle);
$im2->destroy();
Upvotes: 0