Can't use ImageMagick from Ruby: uhdr lib problem

Since an auto-update several days ago I found that I can no longer use pdfbeads utility. It creates a PDF from a series of TIFF images, and uses ImageMagick for image processing.

I started digging and found that pdfbeads calls ImageMagick via rmagick ruby gem. During initialization, it checks the file formats which it supports, and fails during ImageMagick import problem. Here’s the essential part of the failing code reproduced via interactive shell:

$ irb
> require 'rmagick'
> Magick.formats
/home/krvkir/.local/share/gem/ruby/3.2.0/gems/rmagick-6.0.1/lib/rmagick_internal.rb:52:in `init_formats': unable to load module '/usr/lib/ImageMagick-7.1.1/modules-Q16HDRI/coders/uhdr.la': file not found @ error/module.c/OpenModule/1293 (Magick::ImageMagickError)
        from /home/krvkir/.local/share/gem/ruby/3.2.0/gems/rmagick-6.0.1/lib/rmagick_internal.rb:52:in `formats'
        from (irb):5:in `<main>'                        
        from /usr/lib/ruby/gems/3.2.0/gems/irb-1.6.2/exe/irb:11:in `<top (required)>'
        from /usr/bin/irb:25:in `load'                  
        from /usr/bin/irb:25:in `<main>'

Surprisingly, ImageMagick by itself, when called e.g. as display shell command, works fine and doesn’t crash.

I tried to reinstall ImageMagick but nothing changed.

I run Manjaro XFCE with the latest LTS kernel, with auto-updates enabled, if that matters. ImageMagick version is 7.1.1.38:

$ yay -Qs imagemagick
local/imagemagick 7.1.1.38-2
    An image viewing/manipulation program

Do you have an idea why it broke and how to fix it?

Where does it come from?

Your system ruby version is still 3.2.0?

https://manjaristas.org/branch_compare?q=ruby

Branch compare indicate 3.2.x for stable and 3.3.x for the other branches

/usr/lib/ImageMagick-7.1.1/modules-Q16HDRI/coders/uhdr.la exist in the imagemagick 7.1.1.39-1 package on Arch

irb is just an interactive ruby shell. I guess I installed if with gem install. (I’m a newbie in Ruby world.)

As for Ruby versions, seems that I have the latest one available in Manjaro repos:

$ ruby --version
ruby 3.2.5 (2024-07-26 revision 31d0f1a2e7) [x86_64-linux]
$ yay -Ss ruby
...
extra/ruby 3.2.5-2 (4.0 MiB 16.2 MiB) (Installed)
    An object-oriented language for quick and easy programming

I guess Ruby doesn’t distinguish gems for sub-minor versions (or what’s the correct term for the number after second dot), so there’s only 3.2.0 folder in .local/share/gem.

Yup, this file presents on my system too.

ImageMagick 7.1.1.39 is available on Manjaro Unstable and Testing branches
Branch compare for Manjaro - imagemagick

Release 7.1.1-39 · ImageMagick/ImageMagick · GitHub

I’ve run out of ideas and rmagick don’t work for me for a different error

btw moving this to third party since this isn’t a system, AUR or flatpack/snap program

Ok, I decided simply to wait until 7.1.1.39 lands into Manjaro stable repo. Will report here whether it fixes the problem or not.

$ yay -Qs imagemagick
local/imagemagick 7.1.1.41-1

The thing is still broken, with the exactly same error.

pdfbeads seems to be abandonware, with the last update 12 years ago:

Have you considered using something else to create PDF files from TIFF images, such as img2pdf, which is in the Manjaro repos?

Or do you need something specific to Ruby?

Nope, Python is even better for me.

I used pdfbeads because it reproduces djvu-like compression algorithm by pdf means, but if img2pdf does the same thing, my problem is solved (and since it supports PDF2000, there’s hope). Thanks for the link!

But still, the problem seems general, so I reported to rmagick directly: uhdr library problem · Issue #1669 · rmagick/rmagick · GitHub

1 Like

Just a small correction/addition to my last post. The pdfbeads | RubyGems.org | your community gem host page does show a version (1.1.3) was released 3 years ago:

Versions:

  1. 1.1.3 January 31, 2022 (60.5 KB)
  2. 1.1.1 May 18, 2014 (60 KB)
  3. 1.0.9 April 21, 2012 (48.5 KB)
  4. 1.0.8 March 05, 2012 (48.5 KB)
  5. 1.0.7 February 10, 2012 (48.5 KB)

So the GitHub page I linked to may have been the old site for pdfbeads. The RubyGems page shows the pdfbeads home page as http://pdfbeads.rubyforge.org/, however I cannot access that page - it just times out.

It seems to have been down a while for many.

https://downforeveryoneorjustme.com/rubyforge.com

A lot of Azure servers seem to have had trouble around 7 hours ago; maybe that was related, though it’s still not accessible (by me) as I type. :man_shrugging:

https://www.thousandeyes.com/outages/

1 Like

Looks for me that ImageMagick package provided by ArchLinux is missing dependency libraries.

When I install libraries manually,

$ sudo pacman -S libultrahdr # Require for uhdr
$ sudo pacman -S libwmf      # Require for wmf

then, it works well

irb(main):001> require 'rmagick'
=> true
irb(main):002> Magick.formats
=> 
{"3FR" => " r-+",
 "3G2" => " r-+",
 "3GP" => " r-+",
 "AAI" => "*rw+",
 "AI" => " rw-",
 "APNG" => " rw+",
 "ART" => "*rw-",
 "ARW" => " r-+",
 "ASHLAR" => "*-w+",
 "AVI" => " r-+",

...(snip)...

Ref. uhdr library problem · Issue #1669 · rmagick/rmagick · GitHub

Thanks

They are in fact listed as optional:

djvulibre (optional) - DJVU support
ghostscript (optional) - PS/PDF support
jbigkit (optional) - JBIG support
libheif (optional) - HEIF support
libjpeg-turbo (optional) - JPEG support
libjxl (optional) - JPEG XL support
libraw (optional) - DNG support
librsvg (optional) - SVG support
libtiff (optional) - TIFF support
libultrahdr (optional) - UHDR support
libwebp (optional) - WEBP support
libwmf (optional) - WMF support
libzip (optional) - OpenRaster support
ocl-icd (optional) - OpenCL support
openexr (optional) - OpenEXR support
openjpeg2 (optional) - JPEG2000 support
pango (optional) - Text rendering

https://archlinux.org/packages/extra/x86_64/imagemagick/

1 Like