Imagick class / method problems

A

Anonymous

Guest
New to PHP and wordpress, but trying to create a contact form where I can upload an image then use IMagick to resize before its sent to recipient.

Problems so far were:
1. WP_Image_Editor_Imagick class wasn't found, so I added a
Code:
require_once('wp-includes/class-wp-image-editor-imagick.php')
; to the calling function
2. WP_Image_Editor class from which Imagick class was extended also wasn't found, so added a require once just before the imagick class to bring that in too.
3. Now I have "Call to undefined method WP_Image_Editor_Imagick::resizeImage()" where resizeImage method can't be seen anywhere in the imagick class - so I switch to "resize" which is there...
4. then I find that "writeImage" is also not there, so I'm go with "save" instead which is there, but getting internal errors like this:
PHP Fatal error: Uncaught Error: Call to a member function getImageFormat() on null in /home/gariochc/public_html/wp-includes/class-wp-image-editor-imagick.php:626

do I have a REALLY old Imagick install on my hosting company's server?

thanks
Guy
 
This is a great solution of all problems you have shared with us. I really appreciate such an approach.
 
The errors you encountered while using Imagick in PHP and WordPress suggest a possible outdated or incomplete installation of the Imagick extension on your hosting server. To resolve the issue, follow these steps:

  1. Confirm Imagick installation: Check with your hosting company if Imagick is installed and up to date.
  2. Update WordPress: Ensure you have the latest version of WordPress and that all core files are updated.
  3. Check dependencies: Verify that required PHP extensions (e.g., "imagick" and "gd") are installed and enabled.
  4. Use autoloading: Utilize WordPress's autoloading mechanism instead of manually requiring classes.
  5. Verify method names: Double-check the method names for the WP_Image_Editor_Imagick class.
  6. Enable error reporting: Turn on PHP error reporting and debugging for more detailed error messages.
 
Back
Top