Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MiniMagick::Invalid 'identify' doesn't return a description for failed with error: #471

Open
darcyds opened this issue Oct 16, 2018 · 13 comments

Comments

@darcyds
Copy link

darcyds commented Oct 16, 2018

hi, thanks for helping take a look at this.

The closest I found so far is "Getting MiniMagick::Invalid due to improper image header "

Minimgack started failing out of the blue and I can't seem to find the cause of it. Most importantly it doesn't return a description as to why it has failed.

identify /tmp/mini_magick20181016-3982-1mu58uf failed with error:

In my error logs it only shows a 500

MiniMagick::Image.new file.path
MiniMagick::Image.open(node['xlink:href'])
MiniMagick::Tool::Convert.new

Thanks!

@janko
Copy link
Member

janko commented Oct 16, 2018

Could you give me more information, at least the image for which this error happens? Ideally you should give me everything I need to be able to reproduce the issue, including the image and a minimal self-contained example that reproduces the issue. E.g. your example shows node["xlink:href"] which I'm assuming comes from Nokogiri, but Nokogiri probably isn't related to the bug.

@svpersteve
Copy link

This might be related to an issue I'm having processing PDFs like this:

MiniMagick::Image.open(resource_file_path)

I get this error:

MiniMagick::Error: identify: error while loading shared libraries: libIlmImf.so.6: cannot open shared object file: No such file or directory

I fixed a similar issue with ImageMagick that came up randomly where specs were failing to process PDFs on Codeship by adding the PDF filetype to the ImageMagick policy before my builds:

sudo sed -i.bak '/policy domain="coder" rights="none" pattern="PDF"/d' /etc/ImageMagick/policy.xml

However, doing this on Heroku hasn't fixed the problem, it looks like I'm missing a libIlmImf dependency?

@darcyds
Copy link
Author

darcyds commented Oct 21, 2018

Am using minimagick to prepare files for print. There is no one particular image that is returning this error. The error is happening on every file that I try to output.

My current suspect now is that there's no file for minimagick to read. What I can't figure is how this started happening out of the blue and why it's persisting.

identify /tmp/mini_magick20181021-3982-14p0hpo failed with error:

Sentry:
failed at: svg = MiniMagick::Image.read svg

    svg = svgNoko.to_xml
    svg = MiniMagick::Image.read svg

    cmd = "convert #{svg.path} #{file.path}"
    system cmd
    output = MiniMagick::Image.new file.path
    output.combine_options do |c|
      c.resize "#{template_dimensions[0]}x#{template_dimensions[1]+3}^"
      c.gravity 'center'
      c.extent "#{template_dimensions[0]}x#{template_dimensions[1]}"
    end

@calebtocco
Copy link

I came across a similar issue the other day, but with the convert command:

image.composite(main_image.resize_to_fill(680, 482).call, gravity: 'north', offset: [5, 1268])

Exception on (app-name): convert /tmp/open-uri20190209-3-1oxlp7t -auto-orient -resize 680x482^ -sharpen 0x1 -gravity Center -background rgba(255,255,255,0.0) -extent 680x482 /tmp/image_processing20190209-3-3mxz2s.jpg failed with error:

The error message was blank. We have it configured to retry jobs such as this, and the second time (with same exact params) it worked just fine. I've only come across this once so far, but did find it strange that there was no failed with error message and that it was successful with no changes the second time around. Probably not enough to go off of, but since it seemed to be an intermittent thing I'm not sure I can reproduce.

@wilkosz
Copy link

wilkosz commented Jun 6, 2019

Having the same issue with svg on ubuntu:

img = MiniMagick::Image.read(data)
MiniMagick::Invalid (`identify /tmp/mini_magick20190606-21762-bt22qgsvg` failed with error:)
identify: no decode delegate for this image format `' @ error/constitute.c/ReadImage/501.

Requires ext for this particular mimeType

img = MiniMagick::Image.read(data, '.SVG')
#<MiniMagick::Image:0x000000000ea335a0 @path="/tmp/mini_magick20190606-21762-b0i29q.svg", @tempfile=#<Tempfile:/tmp/mini_magick20190606-21762-b0i29q.svg (closed)>, @info=#<MiniMagick::Image::Info:0x000000000ea33578 @path="/tmp/mini_magick20190606-21762-b0i29q.svg", @info={}>>

@freyjasdottir
Copy link

freyjasdottir commented Sep 25, 2019

Having a similar problem to the OP with the attached file.

MiniMagick::Error: identify /.../spec/fixtures/two_page_example.pdf failed with error:

Example:

describe 'blank error message when calling pages' do
  let(:pdf_source_file) { File.open("#{Rails.root}/spec/fixtures/two_page_example.pdf" }
  it 'fails with no error message' do
          MiniMagick::Image.new(pdf_source_file.path).pages
  end
end

two_page_example.pdf

@alex-benoit
Copy link

alex-benoit commented Nov 15, 2019

This is the stack trace of such an error - not sure if it's helpful @janko

staging INFO [ActiveJob] [ActiveStorage::AnalyzeJob] [638210cb-e421-4900-8d99-e9ea41f21a48] Performing ActiveStorage::AnalyzeJob (Job ID: 638210cb-e421-4900-8d99-e9ea41f21a48) from Sidekiq(default) enqueued at 2019-11-14T21:17:18Z with arguments: #<GlobalID:0x000055fa60b2cb58 @uri=#<URI::GID gid://viceroy/ActiveStorage::Blob/2895>>
staging INFO [ActiveJob] [ActiveStorage::AnalyzeJob] [638210cb-e421-4900-8d99-e9ea41f21a48]  S3 Storage (422.7ms) Downloaded file from key: bk9tbkh1bchf8j3ugio6uta81lxo
staging ERROR [ActiveJob] [ActiveStorage::AnalyzeJob] [638210cb-e421-4900-8d99-e9ea41f21a48] Error performing ActiveStorage::AnalyzeJob (Job ID: 638210cb-e421-4900-8d99-e9ea41f21a48) from Sidekiq(default) in 1647.03ms: MiniMagick::Error (`identify -format %[orientation] /tmp/ActiveStorage-2895-20191115-9-1ntt6l8.jpg[0]` failed with error:
staging ):
staging /usr/local/bundle/gems/mini_magick-4.9.5/lib/mini_magick/shell.rb:17:in `run'
staging /usr/local/bundle/gems/mini_magick-4.9.5/lib/mini_magick/tool.rb:90:in `call'
staging /usr/local/bundle/gems/mini_magick-4.9.5/lib/mini_magick/tool.rb:38:in `new'
staging /usr/local/bundle/gems/mini_magick-4.9.5/lib/mini_magick/image/info.rb:171:in `identify'
staging /usr/local/bundle/gems/mini_magick-4.9.5/lib/mini_magick/image/info.rb:115:in `raw'
staging /usr/local/bundle/gems/mini_magick-4.9.5/lib/mini_magick/image/info.rb:35:in `[]'
staging /usr/local/bundle/gems/mini_magick-4.9.5/lib/mini_magick/im:in `[]'
staging /usr/local/bundle/gems/activestorage-6.0.1/lib/active_storage/analyzer/image_analyzer.rb:49:in `rotated_image?'
staging /usr/local/bundle/gems/activestorage-6.0.1/lib/active_storage/analyzer/image_analyzer.rb:22:in `block in metadata'
staging /usr/local/bundle/gems/activestorage-6.0.1/lib/active_storage/analyzer/image_analyzer.rb:37:in `block in read_image'
staging /usr/local/bundle/gems/activestorage-6.0.1/lib/active_storage/downloader.rb:15:in `block in open'
staging /usr/local/bundle/gems/activestorage-6.0.1/lib/active_storage/downloader.rb:24:in `open_tempfile'
staging /usr/local/bundle/gems/activestorage-6.0.1/lib/active_storage/downloader.rb:12:in `open'
staging /usr/local/bundle/gems/activestorage-6.0.1/lib/active_storage/service.rb:86:in `open' 
staging /usr/local/bundle/gems/activestorage-6.0.1/app/models/active_storage/blob.rb:217:in `open'
staging /usr/local/bundle/gems/activestorage-6.0.1/lib/active_storage/analyzer.rb:27:in `download_blob_to_tempfile'
staging /usr/local/bundle/gems/activestorage-6.0.1/lib/active_storage/analyzer/image_analyzer.rb:32:in `read_image'
staging /usr/local/bundle/gems/activestorage-6.0.1/lib/active_storage/analyzer/image_analyzer.rb:21:in `metadata'
staging /usr/local/bundle/gems/activestorage-6.0.1/app/models/active_storage/blob/analyzable.rb:47:in `extract_metadata_via_analyzer'
staging /usr/local/bundle/gems/activestorage-6.0.1/app/models/active_storage/blob/analyzable.rb:29:in `analyze'
staging /usr/local/bundle/gems/activestorage-6.0.1/app/jobs/active_storage/analyze_job.rb:11:in `perform'
staging /usr/local/bundle/gems/activejob-6.0.1/lib/active_job/execution.rb:39:in `block in perform_now'
...
staging INFO Sending event 85fd4aa1fbfb4e69adb9807de04c5be9 to Sentry

@janko
Copy link
Member

janko commented Nov 15, 2019

@alex-benoit Thanks, but unfortunately it doesn't tell me much why the error happens.

So far it seems that the ImageMagick command is simply returning a nonzero exit code without any error message, which isn't something MiniMagick can do anything about – it would need to be fixed in ImageMagick itself. I'm open to be proven otherwise.

It could also theoretically be a bug in Ruby where it doesn't correctly stream the stderr of the ImageMagick command back to our Ruby program. But I'd prefer not to consider that option 😛

In order to debug this issue, I would need:

  • the image file
  • minimal self-contained script that reproduces the error, which I can run with ruby script.rb

I've tried reproducing #471 (comment), but no error happened when I tried to execute it. I'm on Mac OS with the following ImageMagick installation:

$ convert -version
Version: ImageMagick 7.0.8-68 Q16 x86_64 2019-10-07 https://imagemagick.org
Copyright: © 1999-2019 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC HDRI Modules OpenMP(3.1) 
Delegates (built-in): bzlib freetype heic jng jp2 jpeg lcms ltdl lzma openexr png tiff webp xml zlib

@bliaxiong
Copy link

bliaxiong commented Dec 14, 2019

I'm having this issue in Ubuntu. I read in svg in XML format and convert it to an .png file.

It works fine on my Mac tho. Not really sure if it's mini_magick or ImageMagick. I'm going to use rmagick to see if it works.

@wilkosz did you find a solution?

Update:
I used the rmagick gem to do the same thing on Ubunutu and it works.

@JoeHampton
Copy link

I just upgraded to Catalina and started having this issue with the blank error message. I had a co-worker try it also on Catalina and they were able to see an error message - some ghostscript error. I tried reinstalling ghostscript and that error stopped happening for me. Might be worth a shot?

@coding-bunny
Copy link

Running into this problem both on Catalina and our CircleCI Environment.
None of the above approaches seem to be working for us.

@abratashov
Copy link

@denmarkmeralpis
Copy link

I experienced the same thing on my Ubuntu server. However, I solved it by installing ghostscript and libgs-dev

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests