Merge commit '5d4dbbcc67c98007d417cbe67b5a2261889304dc' into glitch-soc/merge-upstream

This commit is contained in:
Claire committed 2024-06-30 11:25:40 +02:00
commit d2aea85e6c
164 files changed
+1857 -1159

No files matched your search

+12 -23
View File
@@ -116,34 +116,23 @@ module Paperclip
# The number of occurrences of a color (r, g, b) is thus encoded in band `b` at pixel position `(r, g)`
histogram = image.hist_find_ndim(bins: BINS)
# `histogram.max` returns an array of maxima with their pixel positions, but we don't know in which
# band they are
# With `bandunfold`, we get back to a (BINS*BINS)×BINS 2D image with a single band.
# The number of occurrences of a color (r, g, b) is thus encoded at pixel position `(r * BINS + b, g)`
histogram = histogram.bandunfold
_, colors = histogram.max(size: 10, out_array: true, x_array: true, y_array: true)
colors['out_array'].zip(colors['x_array'], colors['y_array']).map do |v, x, y|
rgb_from_xyv(histogram, x, y, v)
end.flatten.reverse.uniq
colors['x_array'].zip(colors['y_array']).map do |x, y|
rgb_from_hist_xy(x, y)
end.flatten.reverse
end
# rubocop:disable Naming/MethodParameterName
def rgb_from_xyv(image, x, y, v)
pixel = image.getpoint(x, y)
# 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.
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)
end
def rgb_from_hist_xy(x, y)
r = ((x / BINS) + 0.5) * 256 / BINS
g = (y + 0.5) * 256 / BINS
b = ((x % BINS) + 0.5) * 256 / BINS
ColorDiff::Color::RGB.new(r, g, b)
end
def w3c_contrast(color1, color2)
-3
View File
@@ -42,7 +42,6 @@ namespace :branding do
output_dest = Rails.root.join('app', 'javascript', 'icons')
rsvg_convert = Terrapin::CommandLine.new('rsvg-convert', '-w :size -h :size --keep-aspect-ratio :input -o :output')
convert = Terrapin::CommandLine.new('convert', ':input :output', environment: { 'MAGICK_CONFIGURE_PATH' => nil })
favicon_sizes = [16, 32, 48]
apple_icon_sizes = [57, 60, 72, 76, 114, 120, 144, 152, 167, 180, 1024]
@@ -56,8 +55,6 @@ namespace :branding do
rsvg_convert.run(size: size, input: favicon_source, output: output_path)
end
convert.run(input: favicons, output: Rails.public_path.join('favicon.ico'))
apple_icon_sizes.each do |size|
rsvg_convert.run(size: size, input: app_icon_source, output: output_dest.join("apple-touch-icon-#{size}x#{size}.png"))
end