Batch replace colour images, except a specific colour on Linux - linux

I have 456 .PNG icons with a white image on a blue background, but the background is pixelated. So when I use mogrify to replace a colour, lots of parts of the icon won't become the red colour I want, and stay in a shade of blue. Is there a way to replace all colours, all shades of blue, and keep the white icon intact? Because mogrify recolouring the icons would turn the whole icon red, even the white part.
I have a feeling the solution should be simple, but after some googling and some messing around with Imagemagick and Phatch, I can't seem to figure it out.
I kind of need a batch solution, since theming all the icons manually would be... Something I don't want to do.
I am open for any suggestions and I apologizs in advance if this question turns out to be a duplicate!
If you need more information, just ask, and I can give it to you!

The "+opaque color" option will select all colors except the named one, and turn them to the fill color. Thus,
mogrify -fill red +opaque white *.png
will turn everything except the white pixels to red.

Related

Given a Primary color, how to decides what will be the OnPrimary color by material design guidelines?

In the material color tool there is a place where you choose the primary color and it shows you the text color on primary.
Given a color in hexadecimal string, how to know what will be the suggested text color on that color?
e.g.
Some colors will suggest that the text should be black
Others will say that it should be white
Observation: Any language is ok, just want to know what is the logic / function to do it.
They wrote something about text legibility. Apart from that, I played around a bit. It seems like it's a weighted mean of the r,g,b parts of the color. Blue has significantly moreimpact than green, which has slightly lessimpact than red. So it is probably something like (1*r + 0.9*g + 1.2*b) / 3.1 > 0xff (2.85 is the sum of the weights). If it surpasses the threshold, the text is black, else it is white.
In react's material-ui they have a "formula" to create it, which uses the same logic as material components.

Create an image or photo that can change colour in Tkinter

I need to display an outline of a dog in a window. I then need to be able to change the colour for different part of the dog by inputting numbers into entry boxes- for example if I put a '1' in the 'head' entry box, the head changes to a yellow colour. The dog should be white by default.
I can just create 4 images (one for the head, body, legs, and tale) to change each part of the bod. I've thought about changing the rgb values of each image to change the colour, but this would also change the colour for the outline (meant to stay black). The only other thing I could think of was making a red, blue, green, yellow, blue, etc. version of each image (head, body, legs, tail), and then just displaying the red version of the image when I need to (and the same for other colours).
I need to know if there is any other way to do this (perhaps with the canvas widget?) before I code it because It will take a long time to change the colour of each image. I just have no idea where to start.
Thanks in advance for your answers
You will have to make different widgets for each part of the dog(e.g: Head, Abdomen etc.) and you will need different images for the dogs part and color, after that you can implement a button that changes the color with the 'if' function.

Configure highlight of repeated text in Sublime 3

When you double click on text, it highlights the current text and then places a thin blue border around repeated text. I want to make this thin blue border thicker and change it to white for easier visibility. Can this be configured? Thank you.
The highlighting you are referring to is controlled by the match_selection preference. I'm just mentioning this here in case it helps others find this Q/A pair in future.
It seems that the color for this is controlled by the caret color in your color scheme. However, it seems that there is no way to change the color without changing the color of the caret, or make the border thicker. There is an open feature request for the latter here: https://github.com/SublimeTextIssues/Core/issues/453

Remove all but certain colors (color range) in an image?

I have a grayscale image, which has a certain wanted pattern of colours + some unwanted colors.
The colors I want to leave are (rgb):
000
666
121212
181818
242424
303030
363636
424242
As you can see, there's a pattern. Umfortunately there are some really "hard to select" colors also. The colors are actually contours (curves for height changes of the terrain), so they would be really tiresome to edit manually. The image is 2048 x 2048 pixels.
How could I somehow limit the image just to have those certain colors and maybe even automagically convert the wrong ones to those wanted ones?
You could try converting the image mode to indexed color:
Then choose a custom pallet:
Then add your custom colors to the pallet. Set dither to none. It should convert all colors to the index color they are closest to.
To remove the white lines... convert mode back to rgb, use magic wand to select all white lines (uncheck contiguous and set tolerance to around 10). Then choose select>modify>expand and expand selection by 1 pixel. Now choose edit>fill and choose content-aware.
This should fill in the lines with the colors around them.
Set color to index again to clean up the blured shape edges.
Hope this helps.

Tinting Drawn Textures with the Color property in XNA / Monogame, how to balance?

I have these four icons that look like this:
But I want to be able to just have 1 gray icon and then tint them different colors by setting the color in XNA / Monogames Draw function.
I took one of the images and pulled all the colour out and made it a bit lighter it to get
I also tried a version where the center of the gray image is fully white but neither look right in the game, here's an image with the icons on top and my tinted gray on the bottom (the tint color is sampled from the center of the original icons):
I figure there should be a way, given the original icons, to figure out how to make the gray icon and also the colors to plug into the draw function so that I get an exact copy of the original. I assume this is possible? How do you do it?
EDIT:
To elaborate on my issue here is another image all with blue icons, the top images are all the original blue icon for comparison. The bottom images are all grey icons I used to tint to make the middle icons. The grey icons are, from left to right, 0 saturation, 0 saturation and 100 brightness, and auto level + 0 saturation. It seems to me that by setting the saturation to 0 I am losing the ability to make the icon look right as it's not just "darker" blue but also "bluer" blue.
EDIT 2: I don't think it's possible, thanks for the help Goose.
Would it work if the grey icon was full white at the center (it's brightest point) and got darker from there.
Then you could just sample the color at the center of your source image (the colored ones) and tint with that.
I think the issue you are seeing now is that the grey image will darken the color you are tinting with, so you actually want to tint with the source color PLUS the amount of grey at the brightest point in the image (if that makes sense).

Resources