Hy there,
I have a shared hosting account. They installed Image Magick on my request. But I get this error.
PHP Fatal error: Class 'Imagick' not found in /home/hamrohos/public_html/test.php on line 6
I told them what was wrong. They replied
ImageMagick is installed, but php extension of Imagick is not enabled on shared accounts
Now my question is Can I use Image magick or its any features if its php extensions are not enabled?
Currently I am using GD library but it doesnot have all features of image magick.
I have following features disabled too.
phpinfo(), exec(), system(), passthru()
Without enabling ImageMagick extension in PHP, you won't be able to use the functions it providesdirectly.
The only way to use ImageMagick in this scenario would be to call it with a system function and execute everything as a shell script. You would have to save the image data on disk to do this and after processing them with imagemagick, you would have to load them again.
Thus, It would definitely be feasible, but with severe overhead and changes to your scripts.
Related
I am new to imagemagick and wanted to use some of fred scripts on my managed Sever (Hetzner - linux server). Imagemagick is installed and core features like convert works but how do I call the script? When I try to run something I don't receive any errors and results. As example for the "3Drotate" script I am using this php code
exec("3Drotate pan=45 auto=zc input.jpg 3d_output.jpg", $array, $return);
The script I downloaded lies in the same directory where I call this function (so not in the /bin where imagemagick is installed but in some www/public dir).
I tried to use an absolute path and setting the temp dir in the imagemagick script - both approaches didn't help.
Did you follow the instructions on my home page for installing the scripts? See the Pointers for Use sections.
After doing so, try:
<?php
exec("bash 3Drotate pan=45 auto=zc input.jpg 3d_output.jpg 2>&1", $out,$returnval);
foreach($out as $text)
{echo "$text<br>";}
?>
Do you get any error messages?
Please note my scripts need to be licensed, if used for commercial purposes. My contact information is in the scripts and on my home page. You may contact me offline for more help, if the above does not work.
I try to upload a product image to my Spree app, but i get this error
5errors prohibited this record from being saved:
Attachment Paperclip returned errors for file 'index.jpg' - check ImageMagick installation or image source file.
Attachment Paperclip::Errors::NotIdentifiedByImageMagickError
Attachment Paperclip::Errors::NotIdentifiedByImageMagickError
Attachment Paperclip::Errors::NotIdentifiedByImageMagickError
Attachment Paperclip::Errors::NotIdentifiedByImageMagickError
Should i install a gem, relocate my src image? Whats the problem here
You should to install ImageMagick. Follow these steps for install on Windows:
Download ImageMagick (you need to choose static version for your 32/64 bit OS)
Checked Add application directory to your system path and install
Reopen your command prompt to reload your PATH variables
Run convert -v to check the install worked
Okay so the problem is pretty complicated and after trying to solve it for about 3 hours i finally got it.
First, you have to remove the convert.exe from your System32 files.
We do this, because the Spree app relies on legacy code and when it
tries to upload the image the default convert.exe starts, we don't
want that.
Second you download and install the dynamic installation from the imagemagick site and you have to be sure to check the legacy support so the convert command gets supported.
I dont know if you have to, but i installed the paperclip gem. You may have to do that for it to work.
The whole reason this bug happens, is because Windows. So if you are new to this party, dual boot your station or swap to Ubuntu/Mac whatever. Seriously though, when the app tries to upload it uses the convert command, but convert is already a default Windows command so you can't upload the picture properly. So we disable the command and then we replace it with our imagemagick installation. That's it.Also good luck trying to delete the convert.exe from system32, its a weird process, but you can solve it with some google-fu.
Thanks to Michael for pointing me to right way.
What is the difference between Imagemagick and Imagick ?
How do I configure Imagick to work with IIS and php 5.4.14?
Side-note, ImageMagick is not a "PHP Utility" it's a command line utility that existed before PHP. It can be used by many programs, or by people directly, to manipulate images.
Wherea Imagick is a native implementation of the ImageMagick API for PHP -- https://www.php.net/manual/en/intro.imagick.php
I know my answers are trivially different, but when it comes to a lot of things (including programming), the devil is in the details.
I unfortunately have no reference for installing PHP with Imagick/ImageMagick on Windows/IIS But I assume the DLL answer to be the correct one.
Imagick is a php API for Imagemagick.
Find the correct dll, uncomment imagick in php.ini and prepare to spend some time getting it working.
ImageMagick is a PHP utility, a command line tool for image manipulation.
For further details, see this.
Imagick is an API or a class that performs the function same as ImageMagick. It provides numerous functions for image manipulation in PHP. Refer to this for more details.
For imagick, you need ImageMagick as well. Run the following command for the same.
sudo apt-get install imagemagick php5-imagick
The installation is well explained with requirements in PHP manual.
ImageMagick vs Imagick
ImageMagick® is a free and open-source software suite for displaying, converting, and editing raster image and vector image files. It can read and write over 200 image file formats, and can support a wide range of image manipulation operations, such as resizing, cropping, and color correction. -- excerpt from the publisher's site.
ImageMagick may or may not be installed on your system, and was independent of PHP and IIS. While it is a popular image editing program, windows users may be uncomfortable with the absence of a gui; it is mostly run from the command line.
Imagick is the name given by PHP to its extension to ImageMagick. Imagick extends PHP by wrapping or using much of the source code of ImageMagick, but not necessarily the files installed with ImageMagick.
Install Imagick Extension
To enable PHP's Imagick extension for use by a FastCGI module and the PHP CLI, the Imagick PECL package had to be installed. Caveat: instructions herein apply to webservers that use a FastCGI module to call PHP, not a sapi (server) module.
You can start with PHP's windows site, which links to PECL extensions
Use search, or browse >> 'Images', for Imagick, for the link to the Imagick PECL package.
On the PECL package page, links to the windows packages were labelled 'DLL.' Follow the link to the latest package. If you're on the DLL version page, select for your PHP, architecture (x86 32-bit or x64), and thread safety (TS or NTS). FastCGI PHP always needed NTS (non-thread safe). Confirm your requirements with phpinfo.
Download the PECL package and extract it to a folder of your choice, like imagick_php. On windows, it could be 'c:\imagick_php'. Also on windows, imagick_php size could be reduced by 2/3 by moving out or deleting all *.pdb files.
Make imagick_php available to Imagick, by adding the path to imagick_php to a PATH environment variable.
Options:
Set system environment PATH variable; makes imagick_php available to software on your system that refers to the PATH variable, including PHP CLI and FastCGI, but requires a reboot.
If you use IIS much more than PHP's CLI, you can share Imagick only with PHP as FastCGI, and without a reboot.
In Administrative Tools > IIS Manager > Server > FastCGI Settings, find the 'application' that corresponds to the site's > Handler Mappings > PHP-FastCGI > Executable.
Editing that 'application,' add a variable to the Environment Variables collection: Name path, Value c:\imagick_php;%path%.
Copy the php_imagick.dll from imagick_php to PHP's extension_dir. On windows, it could be 'c:\php\ext'
Instruct PHP to load the Imagick extension on start up. In php.ini, add the line extension = imagick, PHP 7.2+ figures out the path and .dll file name.
Confirm PHP loads Imagick without error. Either browse to a phpinfo file and look for an imagick section, or if your PHP's CLI is setup, set path=c:\imagick_ph;%path% followed by php -d extension=imagick -m, and look for imagick in the list of loaded modules.
Confirm Imagick extension functionality:
Copy examples/captcha.php from imagick_php folder to the webserver site. If on Windows, edit captcha.php, update setFont('Tahoma') or another font on your system.
Finally, browse to the url of captcha.php. Expect a captcha image to be displayed.
For the first question, I think you are asking the difference between ImageMagick (not Image magick) and imagick. PHP Manual gives an explanation http://php.net/manual/en/intro.imagick.php.
For the second question, it is too broad to answer. Maybe you could ask one specific aspect or problem you met.
I'm trying to setup ImageMagick so I can use the Paperclip gem for Ruby on Rails. I've looked at pretty much every question on StackOverflow about the issue, but they all just skip over my issue, that none of the ImageMagick commands are recognized on the CommandPrompt.
I downloaded and then installed ImageMagick-7.0.1-1-Q16-x64-dll.exe on this page
I installed the program to my C: directory, so that there wouldn't be an issue with spaces in the Path, and I used all default installation selections and even selected "Install development headers" which some answers said to do. My issue is that when ImageMagick finishes installing, and it says to test some commands (like "convert -version) on Command Prompt, they all result in
"'convert' is not recognized as an internal or external command ...."
On the command prompt. What could be an issue? Every step-by-step tutorial automatically assumes that these commands are recognized. Most troubleshooting involves steps afterwards.
Here's the documentation for paperclip. All I have to do is make sure the gem has access to ImageMagick, by putting in the development.rb file:
Paperclip.options[:command_path] = "/usr/local/bin/"
In order to find that path above, however, the documentation says to type "which convert". I've researched this and apparently that's a Unix command, and not something for Windows.
So basically, what steps do I need to take so that paperclip has access to ImageMagick? Why aren't basic ImageMagick commands recognized, even after a completed installation?
When you install ImageMagick under Windows, they is a button you need to check that tells the script to install "legacy" utilities such as convert. Reinstall, click on this button, and convert is ready to use. Alternatively, install ImageMagick 6.X which deploys convert automatically.
Windows users, I've answered most of this here.
The windows command line won't run which convert. You'll need to use something like git bash.
Reinstalling image magick won't hurt. You could try another file. I know the dll one (you mentioned) is top of the list, the next one is 64bit as well. You must check every option at install as paperclip will use lots of image magick functionality behind the scenes so check all options. Then restart the system.
in command before typing convert you have to type in magick then convert
keep in mind you are using a newer version of IM hence you have to start by typing 'magick' and then follow other command
my employers have a requirement to upload very large hi-res images. Ordinarily uploading such images does not work.
I was told using ImageMagick would help shift the image processing burden to the Linux server instead of php (so I don't have to set the php max_memory to some ridiculous level).
Anyway, I followed this tutorial: http://thewichitacomputerguy.com/blog/how-enable-install-imagemagick-drupal
I got the following response:
* warning: file_exists() [function.file-exists]: open_basedir restriction in effect. File(/usr/bin/convert) is not within the allowed path(s): (/var/www/vhosts/mysite.co.uk/httpdocs:/tmp) in /var/www/vhosts/mysite.co.uk/httpdocs/includes/image.imagemagick.inc on line 55.
* No file /usr/bin/convert could be found. PHP's open_basedir security restriction is set to /var/www/vhosts/mysite.co.uk/httpdocs:/tmp, which may be interfering with the attempts to locate ImageMagick.
I have determined the /usr/bin/convert file definitely exists on the server but I am at a loss regarding how to proceed.
Can you guys help a drupaler out?
If you're on shared hosting, you will need to speak with your provider. If you administer your server, you will need to edit your php.ini to allow open_basedir access to your imagemagick directory.
ImageMagik always give me a hard time...
That tutorial you cited isn't the way that I typically go about installing it. I think that installing ImageMagik to your /includes folder could be related to the problem. If you want to continue to try to make that work, then try configuring ImageMagik in the Drupal admin pages to look in the right place:
admin/settings/imageapi/config
(assuming you've got the ImageAPI module)
If you can't make the magik happen in there.. I'd try installing ImageMagik with SSH (assuming you've got shell access, because this is a dedicated server)
To do that get yourself Putty
Then figure out what distro of linux you are running (check your host's forum, or ask them.. or try this) and run a command like this:
apt-get install imagemagick
or like this..
yum install imagemagik
Once you get it you'll just need to test it and set up the Drupal image handling with ImageCache
A few cool related modules (once you get it working):
ImageField focus
Avatar crop