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
Related
cable_ready 4.5.0
rails 6.1.4.1
ruby 3.0.2p107
This is a simple example from the basic tutorial (https://www.youtube.com/watch?v=F5hA79vKE_E) I suspect the error I am getting is because either cable_ready or rails evolved a little and created a tiny incompatibility.
I get this error in the JS console:
It is triggered when in my controller I ask cable ready to:
cable_ready["timeline"].console_log(message: "***** cable ready post created")
Which leads to my timeline_channel to:
received(data) {
console.log("******** Received data:", data.operations)
if (data.cableReady) CableReady.perform(data.operations)
}
My interpretation is perform causes this line in cable_ready.js line 13:
operations.forEach(function (operation) {
if (!!operation.batch) batches[operation.batch] = batches[operation.batch] ? ++batches[operation.batch] : 1;
});
Is finding something in the received data that it doesn't like.
That's where my trail ends. Can someone see what I am doing wrong, or tell me what other code you'd like me to include?
Solution: downgrade the version of the cable_ready javascript library.
I previously (maybe a year ago) did this tutorial using CableReady 4.5, Ruby 2.6.5 and Rails 6.0.4 and it worked like a charm back then as well as today.
But today, I tried this tutorial again on a duplicate project--same versions of CR, Ruby, and Rails and now I get java console errors similar to yours.
TypeError: undefined is not a function (near '...operations.forEach...')
perform -- cable_ready.js:13
received -- progress_bar_channel.js:8
I looked at the output of yarn list and saw that cable_ready was version 5.0.0-pre8 on the bad project and it was 5.0.0-pre1 on the good project. The downgrade could be accomplished with yarn add cable_ready#^5.0.0-pre1 in the bad project folder and now both projects work.
FYI for other newbies like me trying to understand how CableReady works: This tutorial gives another example of CableReady, and was also fixed the same way.
I'm trying to make the PDF file with signature with origami gem, follow this example https://github.com/gdelugre/origami/blob/master/examples/signature/signature.rb
Now i just run this signature.rb and got error
[error] Breaking on: ">>\nendobj\n..." at offset 0x1f6f3
[error] Last exception: [Origami::InvalidObjectError] Failed to parse object (no:43,gen:0) -> [ArgumentError] wrong number of arguments (given 1, expected 0; required keyword: year)
I have no idea to move forward :'<
I also found the sign method of gem at https://github.com/gdelugre/origami/blob/master/lib/origami/signature.rb, and have take a look, I can't find any specific things to do :'<
Might this example is outdate?
The error message is known see https://github.com/gdelugre/origami/issues/80
A fix should be available https://github.com/gdelugre/origami/pull/74/commits
But has not been added so use newer file from the fork https://github.com/pocke/origami/tree/fix-ruby-2.7-kwargs-warnings
Specifically you need this updated file and may need to follow any other suggestions from above.
https://github.com/pocke/origami/raw/fix-ruby-2.7-kwargs-warnings/lib/origami/filters/predictors.rb
However it always worth looking for a fork with many more recent improvements such as
https://github.com/joelsondrew/origami
I'm receiving an error message: error "Windows - No Disk Exception Processing Message 0xc0000013 Unexpected Parameter" when I run - magick Test.png Test.txt
The error message in the DOS window is:
Magick: unable to open image'Test2.txt' : Permission denied # error/blob.c/OpenBlob/3537
I guess I'd describe myself as a lower intermediate programmer. This is my 1st time asking a question here as a new member. The first three times I did this command it worked perfectly. But now I'm getting this error message, and I'm not doing anything different. I really need to get these text files generated from the png files, so I hope that some can help. Probably something very simple, but any advice would be much appreciated.
I was configuring the transparency in my rc.lua file for my awesome wm. I am now getting the error mentioned in the title. I have since opened up my original rc.lua thats located in /etc/xdg/awesome/rc.lua and made it exactly the same, yet i still get this error. Any thoughts?
client.connect_signal("focus", function(c) c.border_color = beautiful.border_focus end)
client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
I got the Error when installing a new Theme, but I guess it could be the same problem.
The two mentioned lines are perfectly fine, the error message is misleading!! The problem was (in my configuration at least) a wrong path to my theme file:
# This was the original line:
# beautiful.init("~/.config/awesome/themes/Darklooks/")
# and now the working full path to my theme file:
beautiful.init("~/.config/awesome/themes/Darklooks/theme.lua")
I am trying to detect a pattern shown in two images. Hence I have been trying to use the SURF algorithim found in emgu.CV, but the "SURFFeature" example that is given gives me the following error:
An unhandled exception of type 'Emgu.CV.Util.CvException' occurred in Emgu.CV.dll
Additional information: OpenCV: norm == NORM_L1 || norm == NORM_L2 || norm == NORM_HAMMING
Any ideas how to fix this?
When I try the "Hello World" example and the face detection example, both seem to work fine.
Thanks for any advice!
Fouad.
PS: Emgu.CV can be downloaded from here: http://www.emgu.com/wiki/index.php/Main_Page
Apparently the build was messed up.
http://www.emgu.com/bugs/show_bug.cgi?format=multiple&id=74
Aha, found it. The error here is in Emgu.Cv.Gpu/GpuBruteForceMatcher.cs lines 22 and 27.
Line 22 currently reads:
L2Dist,
It should read: L2Dist = 4,
Line 27 currently reads: HammingDist
It should read: HammingDist = 6
Rebuild the Emgu.CV.Gpu dll with those changes and it works.