Openresty and Imagemagick error: loop or previous error loading module 'magick'

1,363 views
Skip to first unread message

Porfus

unread,
Dec 11, 2013, 10:23:09 AM12/11/13
to openre...@googlegroups.com
I use Openresty 1.4.3.3 and want to use Imagemagick library using magick from Lefao. Settings are made from the description http://leafo.net/posts/creating_an_image_server.html.

In this configuration:
location @image_server_test
        {
                default_type text/html;
                content_by_lua '
                        ngx.say("test") 
                        local magick = require "magick"

                ';
}
location ~ ^/imaget/(?<sig>[^/]+)/(?<filename>.*)/(?<pagenumber>.*)/(?<width>[^/]+)$
        {
              root /var/data/image_cache;

              try_files /test.png @image_server_test;
        }

In  nginx logs get the error:

2013/12/10 04:10:09 [error] 5455#0: *83 lua entry thread aborted: runtime error: [string "content_by_lua"]:3: loop or previous error loading module 'magick'
stack traceback:
coroutine 0:
        [C]: in function 'require'
        [string "content_by_lua"]:3: in function <[string "content_by_lua"]:1>, client: 192.168.100.1, server: , request: "GET /imaget/725379571b2fd8fa3ab993b155839c1f/411a66c81a0edbe3ea5bb383ff4caf64/1/800 HTTP/1.1", host: "192.168.100.132"

What could be wrong?

leaf corcoran

unread,
Dec 11, 2013, 11:36:58 AM12/11/13
to openre...@googlegroups.com
I don't know why you can't see the error message within OpenResty but here's how you can debug it:

magick requires luajit so make sure you've built OpenResty with the flag --with-luajit

If the issue still persists then you can try loading the module outside of OpenResty, if you installed it in the default place you can run:

$ /usr/local/openresty/luajit/bin/luajit
> require "magick"



--
You received this message because you are subscribed to the Google Groups "openresty-en" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openresty-en...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Porfus

unread,
Dec 12, 2013, 10:56:32 AM12/12/13
to openre...@googlegroups.com
I tried and got the error:

>  require "magick"
sh: 1: MagickWand-config: not found
/usr/local/share/lua/5.1/magick/init.lua:147: Failed to load ImageMagick (MagickWand)
stack traceback:
[C]: in function 'try_to_load'
/usr/local/share/lua/5.1/magick/init.lua:147: in main chunk
[C]: in function 'require'
stdin:1: in main chunk
[C]: at 0x00405050

среда, 11 декабря 2013 г., 22:36:58 UTC+6 пользователь leaf corcoran написал:

leaf corcoran

unread,
Dec 12, 2013, 11:10:07 AM12/12/13
to openre...@googlegroups.com
It means it can't find the shared library magickwand, which is part of imagemagick. First make sure you have imagemagick installed (and the dev version if your distro does that). I've seen some distributions put magickwand in a separate package so look for a magickwand (or magcikwand-dev) package to install if it still doesn't work

If you get it working tell me what you needed to do and I'll update the readme.

Thanks (and sorry for hijacking the OpenResty mailing list)

Porfus

unread,
Dec 12, 2013, 11:32:51 AM12/12/13
to openre...@googlegroups.com
I installed the package libmagickwand-dev, now getting another error:

> require "magick"
stdin:1: loop or previous error loading module 'magick'
stack traceback:
[C]: in function 'require'
stdin:1: in main chunk
[C]: at 0x00405050

четверг, 12 декабря 2013 г., 22:10:07 UTC+6 пользователь leaf corcoran написал:

Porfus

unread,
Dec 14, 2013, 12:12:00 AM12/14/13
to openre...@googlegroups.com

I found what was the problem! 
I used require "magick" and you had the require ("magick").
I badly know lua so I can't tell the difference between these records, but it works.


четверг, 12 декабря 2013 г., 22:10:07 UTC+6 пользователь leaf corcoran написал:
Reply all
Reply to author
Forward
0 new messages