Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImageMagick can't use JPEG (OSX/X11)?

Trying to give RMagick a whirl, using Mac OSX and homebrew.

Versions: Mac OSX 10.7.5, HomeBrew 0.9.4., Ruby 2.0, Rmagick 2.13.2, ImageMagick 6.8.6-3.

Here is my Ruby code, in a file named rename.rb:

require 'RMagick'
include Magick

cat = ImageList.new("test.jpg")
cat.display
exit

and here is my terminal output:

rename.rb:5:in `display': delegate library support not built-in `test.jpg' (X11) @ error/display.c/DisplayImages/16067 (Magick::ImageMagickError)
    from rename.rb:5:in `<main>'

It seems though I have the proper delegates installed (I'm not entirely sure, however, since I'm a n00b at ImageMagick). If I run convert -list configure, I get this:

...
DELEGATES      bzlib fontconfig freetype jng jpeg png rsvg tiff xml zlib
...

any ideas? Thanks!

like image 626
aljabear Avatar asked Aug 09 '13 14:08

aljabear


1 Answers

The image has been read and processed successfully, your error is being thrown by cat.display It is not an image format delegate missing, but a window display one.

You will see the same error message on the command line if you simply type:

display test.jpg

So this is an Image Magick issue, not an RMagick or Ruby one.

It seems that the display method is designed to work with X11 windowing, which is not a default feature on Mac OS X. You may be able to re-build it including an X11 service and libary. I use XQuartz for X11 support, but installing it after Image Magick (as I did) won't fix this issue. So, I get same error as you, but I don't use display, I just use a command like open test.jpg on the command line, or:

`open test.jpg`

from Ruby. This is not a platform-agnostic solution, but I can view the images I process just fine.

Alternatively, you could try re-installing Image Magick and rmagick with X11 support (provided of course that you have an X11 service installed such as XQuartz):

brew unlink imagemagick
brew install imagemagick --with-x11
gem install rmagick

I have tested this, and it works to so that cat.display will launch a display window. Although I think I will continue to use other viewers myself.

like image 83
Neil Slater Avatar answered Oct 02 '22 18:10

Neil Slater