2025-06-25 22:31:19 +03:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
|
|
module ImageUtils
|
|
|
|
|
module_function
|
|
|
|
|
|
|
|
|
|
def blank?(image)
|
2025-07-02 13:16:47 +03:00
|
|
|
stats = image.stats
|
|
|
|
|
|
|
|
|
|
min = (0...image.bands).map { |i| stats.getpoint(0, i)[0] }
|
|
|
|
|
max = (0...image.bands).map { |i| stats.getpoint(1, i)[0] }
|
2025-06-25 22:31:19 +03:00
|
|
|
|
|
|
|
|
return true if min.all?(255) && max.all?(255)
|
|
|
|
|
return true if min.all?(0) && max.all?(0)
|
|
|
|
|
|
|
|
|
|
false
|
|
|
|
|
end
|
|
|
|
|
end
|