validate signature image

This commit is contained in:
Pete Matsyburka committed 2025-06-25 22:31:19 +03:00
1 parent 2e487ac936
commit ee4acd5a82
1 file changed
+16
+16
View File
@@ -0,0 +1,16 @@
# frozen_string_literal: true
module ImageUtils
module_function
def blank?(image)
min = (0...image.bands).map { |i| image.stats.getpoint(0, i)[0] }
max = (0...image.bands).map { |i| image.stats.getpoint(1, i)[0] }
return true if min.all?(255) && max.all?(255)
return true if min.all?(0) && max.all?(0)
return true if min.length >= 4 && min[-1].zero? && max[-1].zero?
false
end
end