ruby-on-rails-4imagemagickdicomrmagick

LoadError: cannot load such file -- rmagick with dicom gem


I am writing a job that converts dcm to jpg images using the dicom gem

here is the code

require 'RMagick'
require 'dicom'
include Magick
include DICOM


class DicomtojpgJob < ActiveJob::Base
  queue_as :dicom

  def perform(*args)
    puts "were are here"
    dcm_filename = args[0]
    dcm = DObject.read(dcm_filename)
    puts dcm.summary
    dcm_image = dcm.image
    name = dcm_filename.split('.')
    dcm_image.normalize.write(name[0]+".jpg")

    # img = ImageList.new("IM-0004-0044.jpg")
    # img.display
    # args[0].update_attributes(:asset_path_url)
    puts args[0]

    exit
  end

end

here is what i get on console

DICOM Object Properties:Byte Order (CPU):     Little Endian
-------------------------------------------
Source:               File (successfully read): /home/aditya/orthoweb/public/patient-summary-assets/56c6b0b943fe4728c8000007_photo_20160219_122843.dcm

DICOM Object Properties:

Modality:             MR Image Storage-------------------------------------------

Source:               File (successfully read): /home/aditya/orthoweb/public/patient-summary-assets/56c6b0b943fe4728c8000007_photo_20160219_151307.dcm
Modality:             MR Image Storage
Meta Header:          Yes
Value Representation: Explicit
Byte Order (File):    Little Endian
Pixel Data:           Yes
Image Size:           512*288
Number of frames:     1
Meta Header:          YesPhotometry:           MONOCHROME2
Compression:          JPEG 2000 Image Compression

Value Representation: ExplicitBits per Pixel:       16

Byte Order (File):    Little Endian-------------------------------------------

Pixel Data:           Yes
Source:               File (successfully read): /home/aditya/orthoweb/public/patient-summary-assets/56c6b0b943fe4728c8000007_photo_20160219_151307.dcm
Modality:             MR Image Storage
Image Size:           512*288Meta Header:          Yes
Value Representation: Explicit

Number of frames:     1Byte Order (File):    Little Endian

Photometry:           MONOCHROME2Pixel Data:           Yes
Image Size:           512*288

Number of frames:     1Compression:          JPEG 2000 Image Compression

Bits per Pixel:       16Photometry:           MONOCHROME2

-------------------------------------------Compression:          JPEG 2000 Image Compression

Source:               File (successfully read): /home/aditya/orthoweb/public/patient-summary-assets/56c6b0b943fe4728c8000007_photo_20160219_122843.dcmBits per Pixel:       16

Modality:             MR Image Storage
Meta Header:          Yes
Value Representation: Explicit
Byte Order (File):    Little Endian
Pixel Data:           Yes
Image Size:           512*288
Number of frames:     1
2016-02-19T10:07:18.291Z 17868 TID-1ho0x0 DicomtojpgJob JID-4fc6a66b41be878a632b7d9e INFO: fail: 0.014 sec
2016-02-19T10:07:18.291Z 17868 TID-1ho0x0 WARN: {"class"=>"ActiveJob::QueueAdapters::SidekiqAdapter::JobWrapper", "wrapped"=>"DicomtojpgJob", "queue"=>"dicom", "args"=>[{"job_class"=>"DicomtojpgJob", "job_id"=>"345b5c25-82fb-49e7-a59d-b4a5eaf971b6", "queue_name"=>"dicom", "arguments"=>["/home/aditya/orthoweb/public/patient-summary-assets/56c6b0b943fe4728c8000007_photo_20160219_151307.dcm"]}], "retry"=>true, "jid"=>"4fc6a66b41be878a632b7d9e", "created_at"=>1455874987.2288666, "enqueued_at"=>1455876438.270517, "error_message"=>"cannot load such file -- rmagick", "error_class"=>"LoadError", "failed_at"=>1455874987.2376463, "retry_count"=>6, "retried_at"=>1455876438.2907836}
Photometry:           MONOCHROME2
Compression:          JPEG 2000 Image Compression
Bits per Pixel:       162016-02-19T10:07:18.291Z 17868 TID-1ho0x0 WARN: LoadError: cannot load such file -- rmagick

I followed this issue on the github page here It suggested that if i am able to convert the dcm image to jpg directly using the command convert -debug module IM-0001-0001.dcm IM.jpg then dicom should not show any error. I am able to convert it to jpg using the console but dicom is throwing an error 2016-02-19T09:24:03.960Z 14165 TID-1kcakw WARN: LoadError: cannot load such file -- rmagick


Solution

  • The issue was fixed by upgrading rmagick to 2.13.4 or later.