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 get_pixels gives "unable to write file" #552

Open
jeffcovey opened this issue Nov 20, 2022 · 2 comments
Open

MiniMagick get_pixels gives "unable to write file" #552

jeffcovey opened this issue Nov 20, 2022 · 2 comments

Comments

@jeffcovey
Copy link

This has been working for us for years as a quick-and-dirty way to check for duplicate images being uploaded to our Ruby on Rails site:

file.blob.open do |temp_file|
  file_data = MiniMagick::Image.open(temp_file.path)
  file_data.resize '1024x768'
  @md5 = Digest::MD5.hexdigest(file_data.get_pixels.join)
  # etc.
end

After recent Rails upgrades (I believe it started around 6.0.4; we're gradually moving to 7.0), this started throwing errors like:

/home/jeff/.rvm/gems/ruby-3.1.2/gems/mini_magick-4.11.0/lib/mini_magick/shell.rb:17:in `run': `convert /tmp/mini_magick20221120-1647726-dit0yb.png -depth 8 RGB:-` failed with error: (MiniMagick::Error) convert-im6.q16: unable to write file `-' @ error/constitute.c/WriteImage/1341.

I tracked the problem down to get_pixels. Everything works fine until there, including resizing the image in the previous line. Why do we get this error when calling get_pixels? Why is it trying to write a file when getting the pixels matrix?

Thanks for your help!
Jeff

@jeffcovey
Copy link
Author

I asked this on StackOverflow, too, and someone confirmed the problem:

There is probably something wrong with get_pixels. I just installed MiniMagick, opened an image and applied get_pixels and my console was left hanging ... (Rails 7, Ruby 3.1.0)

Can anyone help?

@jeffcovey
Copy link
Author

Is no one there?

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

1 participant