Page 1 of 1

Replace colour in every icon resolution in an .ICO file

Posted: 2017-11-13T17:04:44-07:00
by rossmcm
I have extracted the icons for the command prompt in Windows 10 - using the freeware IcoFX:

Image

I want to create different versions of this icon set with the white pixels replaced with another colour. IcoFX has menu entries for this, but they only act on the currently selected icon size variant, and to do all sizes for a succession of colours will take a long time.

Just to recap, I have the file

Code: Select all

Windows Command Prompt Icon.ico
, and I want to produce files

Code: Select all

Windows Command Prompt Icon (red).ico
Windows Command Prompt Icon (blue).ico
Windows Command Prompt Icon (cyan).ico
...
etc.
(TIA)

Re: Replace colour in every icon resolution in an .ICO file

Posted: 2017-11-13T17:37:14-07:00
by snibgo
If you provided a link to your icon file, we could try it out. If you told us which version of IM you used, we could give the correct command name.

But this might work:

Code: Select all

convert "Windows Command Prompt Icon.ico" -fill Red -opaque White "Windows Command Prompt Icon (red).ico"

Re: Replace colour in every icon resolution in an .ICO file

Posted: 2017-11-13T17:54:42-07:00
by rossmcm
Thanks for answering:

https://www.dropbox.com/s/7mzzrw4rg5iwu ... n.ico?dl=0

Version: ImageMagick 6.9.0-0 Q16 x64 2014-11-14

whoops. Dropbox have gone all stupid with their file sharing: Trying this:
https://www.dropbox.com/s/7mzzrw4rg5iwu ... n.ico?dl=1 (seems to work - right-click and choose "save link as")
and...
https://www.dropbox.com/s/7mzzrw4rg5iwu ... .ico?raw=0 (wants to save it as an html file)
https://www.dropbox.com/s/7mzzrw4rg5iwu ... .ico?raw=1 (seems to work)

Re: Replace colour in every icon resolution in an .ICO file

Posted: 2017-11-13T18:01:34-07:00
by snibgo
Yes, that worked. Repeat for whatever colours you want.

Re: Replace colour in every icon resolution in an .ICO file

Posted: 2017-11-13T18:16:09-07:00
by GeeMack
rossmcm wrote: 2017-11-13T17:04:44-07:00I want to create different versions of this icon set with the white pixels replaced with another colour. IcoFX has menu entries for this, but they only act on the currently selected icon size variant, and to do all sizes for a succession of colours will take a long time.
I get an orange version of the input icon by using IM 6.9.9-20 and this command...

Code: Select all

convert "Windows Command Prompt Icon.ico" -fill orange -tint 100 icon_orange.ico
There seems to be an issue with the transparent background when using IM 7.0.7-11.

Re: Replace colour in every icon resolution in an .ICO file

Posted: 2017-11-13T18:34:46-07:00
by fmw42
@GeeMack: Why are you tinting. Tinting does something else than what the OP requested. It adds tint color to the mid grays.

But I agree that the alpha channel is turned opaque in IM 7.0.7.11. So I would say there is a bug.

Re: Replace colour in every icon resolution in an .ICO file

Posted: 2017-11-13T20:24:23-07:00
by rossmcm
@snibgo Many thanks. Yes, that did the trick.

However. Not really an ImageMagick question but...

The reason I wanted to do this was so that I could differentiate between several command prompt icons on my taskbar

(Image)

but changing the icon file for the taskbar has no effect on the small icon displayed. If I right-click the icon on the taskbar, I can see the different-coloured icon I have set.

Image

It's as if the icons are cached somewhere (I don't suppose you have any ideas...?)

Re: Replace colour in every icon resolution in an .ICO file

Posted: 2017-11-13T21:33:13-07:00
by rossmcm
Found it.

Code: Select all

C:\Users\<your username>\AppData\Local\Microsoft\Windows\Explorer
has the icon cache.

To rectify:
  • open a command prompt
  • type the following commands

Code: Select all

cd C:\Users\<your username>\AppData\Local\Microsoft\Windows\Explorer
taskkill /im explorer.exe /f
del iconcache_*.db
explorer

Re: Replace colour in every icon resolution in an .ICO file

Posted: 2017-11-14T05:29:13-07:00
by snibgo
rossmcm wrote:The reason I wanted to do this was so that I could differentiate between several command prompt icons on my taskbar
Not really IM, but you may find the Microsoft "title" command useful. On my Windows computer, I use:

Code: Select all

title %CD%

Re: Replace colour in every icon resolution in an .ICO file

Posted: 2017-11-14T12:14:21-07:00
by fmw42
The following command seems to work in IM 6.9.9.24 beta and IM 7.0.7.12 beta

Code: Select all

convert "Windows Command Prompt Icon.ico" -fill orange -tint 100 icon_orange.ico

Code: Select all

magick "Windows Command Prompt Icon.ico" -fill orange -tint 100 icon_orange.ico

Re: Replace colour in every icon resolution in an .ICO file

Posted: 2017-11-14T22:06:17-07:00
by GeeMack
fmw42 wrote: 2017-11-13T18:34:46-07:00@GeeMack: Why are you tinting. Tinting does something else than what the OP requested. It adds tint color to the mid grays.
I read the OP too fast and got ahead of myself. I was recently working with several methods for coloring and tinting grayscale weather satellite images to get various similar results. Here's a way to change all levels of white to a color...

Code: Select all

convert "Windows Command Prompt Icon.ico" +level-colors black,orange "Windows Command Prompt Icon (orange).ico"
But I agree that the alpha channel is turned opaque in IM 7.0.7.11. So I would say there is a bug.
The command above also loses transparency with IM 7.0.7-11. It looks like that may be resolved in the next release.

Re: Replace colour in every icon resolution in an .ICO file

Posted: 2017-11-15T15:34:25-07:00
by rossmcm
snibgo wrote: 2017-11-14T05:29:13-07:00
rossmcm wrote:The reason I wanted to do this was so that I could differentiate between several command prompt icons on my taskbar
Not really IM, but you may find the Microsoft "title" command useful. On my Windows computer, I use:

Code: Select all

title %CD%
Thanks @snibgo, I never knew about "title". Could be useful, but of course, it is only useful if there is a command prompt window open. If there isn't, you have to hover over the icon and wait for the hint.

We've drifted off topic a bit, but do you know if there is any way of suppressing the "Administrator:" windows inserts in front of the title string? As it is, I can't see the title because the word "Administrator" fills up most of the title bar:

Image

Re: Replace colour in every icon resolution in an .ICO file

Posted: 2017-11-16T00:31:43-07:00
by snibgo
rossmcm wrote:... suppressing the "Administrator:" windows inserts in front of the title string?
You might need to hack a file. For example, see https://social.technet.microsoft.com/Fo ... tasecurity

Re: Replace colour in every icon resolution in an .ICO file

Posted: 2017-11-16T01:08:20-07:00
by rossmcm
@snibgo, Yep, I found that. Started off on the journey, but the property sheets have changed in Windows 10 since that was written and I got a bit lost/bored/annoyed. As someone else remarked - why doesn't someone write a utility to do it?

Thanks for your help.