2
votes

I am working on creating thumbnail image from the first page of pdf file. I almost tired every solution available on the web to make ImageMagick running but I still get the following error

Fatal error: Class 'Imagick' not found in C:\wamp\www\mediabox\application\controllers\cron.php on line 153

what I have done so far.

  1. Installed GPL Ghostscript
  2. Installed ImageMagick-6.7.6-Q16
  3. Downloaded and copied the php_imagick.dll file in ext folder of my php installation.
  4. Added extension=php_imagick.dll line to my php.ini file.
  5. Restarted the apache server and windows many times :)
  6. I am using codeigniter framework.
  7. Php 5.3.10, apache 2.2.21, mysql 5.5.20, wamp 2.2 and win 7

On my localhost page in the loaded extensions category 'Imagemagick is not listed'

The code I have written is as

$image = explode('.', $filename_new);
$image_name = 'files/import/' . $ftp_upload["path"] ."/". $image[0] .".jpg";
//exec("convert -colorspace RGB -geometry 300x400! -density 200 " .$pdf_file."[0] ". $image_name);  
$img = $image[0].".jpg" ;
$im = new Imagick($img);
$im->pingImage($img);
$im->readImage($img);
$im->thumbnailImage(100, null);
$im->writeImage( 'files/import/' . $ftp_upload["path"] ."/".$img);
$im->destroy();

The exec command create images but it is very slow I want to create thumbnail images using Imagick class and I hope it will be faster as compared to exec and convert thingy.

Any ideas what should I do to make the Imagick class available for my php ?

Thanks

3
check your phpinfo() to see if you have an extension called imagick first. This should confirm whether the imagick extension was installed correctly. - F21
no it does not have imagick extension - Faryal Khan

3 Answers

2
votes

I am not sure where you got your binaries from, but it seemed like something I experienced about a month ago. Some of the binaries I tried would show up in phpinfo(), but refused to work, whereas others wouldn't even show in phpinfo().

I then just went ahead and compiled my own binaries as per my question here.

I just went and compiled those binaries for you. They are for x86, compiled with VC9 and there are threadsafe and non-threadsafe versions. The version is 3.1.0RC1 (latest).

You can download them here: http://min.us/mtg0Z66BI

Let me know if it works for you :)

1
votes

On my server the pecl-imagick extension only works with mod_mpm_prefork - it does not work with mod_mpm_worker.so or mod_mpm_event.so

That may be your issue.

0
votes

If you are only creating jpg add the jpg hint to the exec( ) command which will be faster than Imagick.

Use -define jpeg:size=200x200 before reading the image in - 200x200 is the output image size.

I suspect Imagick is not installed correctly