-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix!: remove support for dominant border colour (broken)
When running specs on ubuntu 24.04, the "dominant" border rendered using completely different and clearly wrong colour. It turns out that this feature is thoroughly broken. Problems: 1. The generated histogram information is plain wrong, suggesting the colours which clearly aren't dominant. These are mostly blueish, with some brownish and two flashy greens. I don't know why that happens, possibly the image preprocessing somehow conflicts with the histogram option. 2. In the ubuntu 22.04's imagemagick version (used to find dominant colours), the pixel count is not padded, leading to incorrect sorting. That happened to have picked the brown-ish value for border colour in the spec example, which didn't look perfect but also wasn't so clearly wrong. However, ubuntu 24.04's imagemagick adds padding to pixel count, so the sorting is correct, but as per point 1. the entire histogram is wrong. This leads to selecting bright green colour for the border. Solution: The colorscore gem seems unmaintained, so one alternative is to reimplement dominant handling ourselves. What made the output sane to me was substituting colorscore's command: convert spec/fixtures/reference_images/plasma-no-op-output.jpg -resize 400x400 -format %c -dither None -quantize YIQ -colors 16 -depth 8 histogram:info:- with the following one: convert spec/fixtures/reference_images/plasma-no-op-output.jpg -resize 400x400 -format %c -dither None -quantize YIQ -colors 16 -depth 8 gif:- \ | convert - -define histogram:unique-colors=true -format %c histogram:info:- \ | sort Ideally the natural sorting should be used to handle unpadded output. That said, I don't expect anyone to miss that feature, so I'm just removing it, leaving the hints to fix it here :) . References: - original code from colorscore: https://github.com/quadule/colorscore/blob/32dad8ee5d7500f01208bc9262e8d4d4f3248642/lib/colorscore/histogram.rb#L6
- Loading branch information
Showing
6 changed files
with
9 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file modified
BIN
+2.49 KB
(100%)
spec/fixtures/reference_images/plasma-bordered-retro-style.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters