imagemagick scripts on managed host - imagemagick

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.

Related

What is the difference between Imagemagick and Imagick?

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.

How to install ImageMagick on Windows 8?

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

How to use luadoc in ubuntu/linux?

As the title says, how to use luadoc in ubuntu/linux? I generated documentation in windows using batch file but no success in ubuntu. Any ideas?
luadoc
Usage: /usr/bin/luadoc [options|files]
Generate documentation from files. Available options are:
-d path output directory path
-t path template directory path
-h, --help print this help and exit
--noindexpage do not generate global index page
--nofiles do not generate documentation for files
--nomodules do not generate documentation for modules
--doclet doclet_module doclet module to generate output
--taglet taglet_module taglet module to parse input code
-q, --quiet suppress all normal output
-v, --version print version information
First off, I have little experience with Luadoc, but a lot of experience with Ubuntu and Lua, so I'm basing all my points off of that knowledge and a quick install that I've just done of luadoc. Luadoc, as far as I can see, is a Lua library (so can also be used in Lua scripts as well as bash). To make documentation (in bash), you just run
luadoc file.lua
(where file is the name of your file that you want to create documentation for)
The options -d and -t are there to choose where you want to put the file and what template you want to use (which I have no clue about, I'm afraid :P). For example (for -d):
luadoc file.lua -d ~/Docs
As far as I can see, there is little else to explain about the actual options (as your code snippet explains what they do well enough).
Now, looking at the errors you obtained when running (lua5.1: ... could not open "index.html" for writing), I'd suggest a few things. One, if you compiled the source code, then you may have made a mistake somewhere, such as not installing dependencies (which I'd be surprised about, because otherwise you wouldn't have been able to make it at all). If you did, you could try getting it from the repos with
sudo apt-get install luadoc
which will install the dependencies too. This is probably the problem, as my working copy of luadoc runs fine from /usr/bin with the command
./luadoc
which means that your luadoc is odd, or you're doing something funny (which I cannot work out from what you've said). I presume that you have lua5.1 installed (considering the errors), so it's not to do with that.
My advice to you is to try running
luadoc file.lua
in the directory of file.lua with any old lua file (although preferably one with at least a little data in) and see if it generates an index.html in the same folder (don't change the directory with -d, for testing purposes). If that DOESN'T work, then reinstall it from the repos with apt-get. If doing that and trying luadoc file.lua doesn't work, then reply with the errors, as something bigger is going wrong (probably).

ImageMagick is installed, but php extension of Imagick is not enabled

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.

Imagemagick setup

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

Resources