Merge remote-tracking branch 'parent/main' into upstream-20240618
This commit is contained in:
commit
aa2cdc898a
271 changed files with 1839 additions and 1397 deletions
|
@ -30,8 +30,10 @@ namespace = ENV.fetch('REDIS_NAMESPACE', nil)
|
|||
cache_namespace = namespace ? "#{namespace}_cache" : 'cache'
|
||||
sidekiq_namespace = namespace
|
||||
|
||||
redis_driver = ENV.fetch('REDIS_DRIVER', 'hiredis') == 'ruby' ? :ruby : :hiredis
|
||||
|
||||
REDIS_CACHE_PARAMS = {
|
||||
driver: :hiredis,
|
||||
driver: redis_driver,
|
||||
url: ENV['CACHE_REDIS_URL'],
|
||||
expires_in: 10.minutes,
|
||||
namespace: "#{cache_namespace}:7.1",
|
||||
|
@ -43,7 +45,7 @@ REDIS_CACHE_PARAMS = {
|
|||
}.freeze
|
||||
|
||||
REDIS_SIDEKIQ_PARAMS = {
|
||||
driver: :hiredis,
|
||||
driver: redis_driver,
|
||||
url: ENV['SIDEKIQ_REDIS_URL'],
|
||||
namespace: sidekiq_namespace,
|
||||
}.freeze
|
||||
|
|
|
@ -122,26 +122,28 @@ module Paperclip
|
|||
|
||||
colors['out_array'].zip(colors['x_array'], colors['y_array']).map do |v, x, y|
|
||||
rgb_from_xyv(histogram, x, y, v)
|
||||
end.reverse
|
||||
end.flatten.reverse.uniq
|
||||
end
|
||||
|
||||
# rubocop:disable Naming/MethodParameterName
|
||||
def rgb_from_xyv(image, x, y, v)
|
||||
pixel = image.getpoint(x, y)
|
||||
|
||||
# Unfortunately, we only have the first 2 dimensions, so try to
|
||||
# guess the third one by looking up the value
|
||||
# As we only have the first 2 dimensions for this maximum, we
|
||||
# can't distinguish with different maxima with the same `r` and `g`
|
||||
# values but different `b` values.
|
||||
#
|
||||
# Therefore, we return an array of maxima, which is always non-empty,
|
||||
# but may contain multiple colors with the same values.
|
||||
|
||||
# NOTE: this means that if multiple bins with the same `r` and `g`
|
||||
# components have the same number of occurrences, we will always return
|
||||
# the one with the lowest `b` value. This means that in case of a tie,
|
||||
# we will return the same color twice and skip the ones it tied with.
|
||||
z = pixel.find_index(v)
|
||||
pixel.filter_map.with_index do |pv, z|
|
||||
next if pv != v
|
||||
|
||||
r = (x + 0.5) * 256 / BINS
|
||||
g = (y + 0.5) * 256 / BINS
|
||||
b = (z + 0.5) * 256 / BINS
|
||||
ColorDiff::Color::RGB.new(r, g, b)
|
||||
r = (x + 0.5) * 256 / BINS
|
||||
g = (y + 0.5) * 256 / BINS
|
||||
b = (z + 0.5) * 256 / BINS
|
||||
ColorDiff::Color::RGB.new(r, g, b)
|
||||
end
|
||||
end
|
||||
|
||||
def w3c_contrast(color1, color2)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue