ImageMagick unable to convert PDF to images on WSL - imagemagick

I was trying to use ImageMagick to convert a PDF to images, but I got this error:
convert-im6.q16: attempt to perform an operation not allowed by the security policy `PDF' # error/constitute.c/IsCoderAuthorized/408.
convert-im6.q16: no images defined `tmp/%03d.png' # error/convert.c/ConvertImageCommand/3258.
I found a bunch of answers (like this and this) that suggests to modify the policy.xml file; my problem is, I have no idea where to find that file on WSL: I tried looking for it in /etc/, with find and searching in Windows, to no avail. Any idea how to solve this issue on WLS?

You can find it like this:
identify -list configure | grep CONFIGURE_PATH
Failing that, use this search.
Failing that, use find in your WSL environment like this:
find / -name policy.xml 2> /dev/null
Failing that, just use Windows' Search to find a file calledpolicy.xml

Related

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

why font list is empty for imagemagick?

I am trying to use ImageMagick to add some text to an image. But I found it always said that my specified font doesn't exist. After reading the manual carefully I noticed that I can use convert -list font to output all the available fonts, but after trying I figured out that the list of available font is empty.
This is what I get:
shell$ convert -list font
shell$
Thanks for any kind of tips.
I just managed to tell ImageMagick about the fonts on my OSX system like this:
# Make a new directory for ImageMagick local settings and cd into it
mkdir ~/.magick
cd ~/.magick
# Grab script to find all fonts on system and store them in a config file
curl -L http://www.imagemagick.org/Usage/scripts/imagick_type_gen > type_gen
# Run script, telling it where my fonts are and create "type.xml" file with list
find /System/Library/Fonts /Library/Fonts ~/Library/Fonts -name "*.[to]tf" | perl type_gen -f - > type.xml
# Go to ImageMagick config folder - see note at end to find correct folder
cd /usr/local/Cellar/imagemagick/6.8.9-1/etc/ImageMagick-6
# Edit system config file called "type.xml" and add line near end to tell IM to look at local file we made in earlier step
<typemap>
<include file="type-ghostscript.xml" />
<include file="~/.magick/type.xml" /> ### THIS LINE ADDED ###
</typemap>
How to find the correct folder for your type.xml file
The folder where type.xml is stored can vary enormously between systems and versions. Most recently the user configuration folder seems to be ~/.config/ImageMagick, but the best way I know of finding it is to run the following command to see where ImageMagick is looking:
convert -debug configure -list font 2>&1 | grep -E "Searching|Loading"
Searching for configure file: "/usr/local/Cellar/imagemagick/7.0.11-6/share/ImageMagick-7/type.xml"
Searching for configure file: "/usr/local/Cellar/imagemagick/7.0.11-6/lib/ImageMagick//config-Q16HDRI/type.xml"
Searching for configure file: "/usr/local/Cellar/imagemagick/7.0.11-6/etc/ImageMagick-7/type.xml"
Searching for configure file: "/usr/local/Cellar/imagemagick/7.0.11-6/share/doc/ImageMagick-7/type.xml"
Searching for configure file: "/Users/username/.config/ImageMagick/type.xml"
Loading type configure file "/usr/local/Cellar/imagemagick/7.0.11-6/etc/ImageMagick-7/type.xml" ...
Loading type configure file "/usr/local/Cellar/imagemagick/7.0.11-6/etc/ImageMagick-7/type-ghostscript.xml" ...
Loading type configure file "/Users/username/.config/ImageMagick/type.xml" ...
So there are lots of places you could insert the fonts. In general, if you choose a folder starting with /etc or /usr/local the fonts will be available for all users and for scripts in your web server to use - if you want that. On the other hand, if you are just a single user, you may prefer to keep the font config file in your login directory, e.g. ~/.config/ImageMagick/type.xml.
With ImageMagic 7.0.10 on MacOs Catalina I have done the following which did the trick.
Edited /usr/local/Cellar/imagemagick/7.0.10-7/etc/ImageMagick-7/type.xml and replaced type-ghostscript with type-apple
Edited /usr/local/Cellar/imagemagick/7.0.10-7/etc/ImageMagick-7/type-apple.xml and added "/System/Library/Fonts/Supplemental" in front of all glyph paths

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).

Rails 3 and rmagick

I have problem with rmagick in Rails 3.
Everything seems to be installed, but I get the following error:
Failed to manipulate with rmagick, maybe it is not an image? Original
Error: unable to open image
`kar/public/uploads/tmp/20110825-1348-30304-9150/thumb_1314198312_by_jannnu11_500.jpg':
# error/blob.c/OpenBlob/2588
File exists. Have good chmod.
This code works on another server.
Any ideas?
In some cases the installation of ImageMagick may have missed some of the file formats required for the image manipulation you are trying to do on that machine.
Try to run identify -list format and see what you are missing from there.
If it turns out that you are just missing the file format, try to uninstall/reinstall and you should be good to go.

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