Embedded Icons copy feature -> upgrade.

Features wanted...
eil
Posts: 1832
Joined: 13 Jan 2011 19:44

Embedded Icons copy feature -> upgrade.

Post by eil »

Properties Tab allows to double-click on embedded icon to copy it in clipboard as BMP with no transparency. Could be useful feature, but useless in this form. So i propose few upgrades:
- Right-clicking on icon allows to select which size would be copied on double-click(choice remembered, at least for current session) = currently it seems to always copy only 32x which is not practical;
- Copy as PNG with transparency = PNG has became the main icon-image interaction format, so it's natural to work with that instead of BMP;
- Possibility not only to copy to clipboard, but optionally save into PNG file = would be useful for fast picking PNG-icons for user buttons and elsewhere;
- Scripting command supporting very same operations - copy/save specific size embedded icon from particular item in to PNG.
Win 7 SP1 x64 100% 1366x768|1900x1080

admin
Site Admin
Posts: 65389
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Embedded Icons copy feature -> upgrade.

Post by admin »

I tried this years ago but it was too hard / not worth the pain.

eil
Posts: 1832
Joined: 13 Jan 2011 19:44

Re: Embedded Icons copy feature -> upgrade.

Post by eil »

Damn, it's just shame that feature is kinda here, but not really, and other tools must be used.(which all have drawbacks and never support proper command line for scripting)
Win 7 SP1 x64 100% 1366x768|1900x1080

admin
Site Admin
Posts: 65389
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Embedded Icons copy feature -> upgrade.

Post by admin »

Icofx works great.

eil
Posts: 1832
Joined: 13 Jan 2011 19:44

Re: Embedded Icons copy feature -> upgrade.

Post by eil »

Judging by their docs, while it does support command line as a thing, it Can't extract exactly one needed icon dimension, only all of them(which is excessive). Plus can't copy to clipboard via command line to operate with data when no files actually needed at all.
Win 7 SP1 x64 100% 1366x768|1900x1080

admin
Site Admin
Posts: 65389
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Embedded Icons copy feature -> upgrade.

Post by admin »

AFAIK the clipboard does not support transparency data anyway, only 24-bit bitmaps.

eil
Posts: 1832
Joined: 13 Jan 2011 19:44

Re: Embedded Icons copy feature -> upgrade.

Post by eil »

Hm, but PNG has transparency and those can be copied to clipboard.. or is that smth else?(not transparency)
Win 7 SP1 x64 100% 1366x768|1900x1080

admin
Site Admin
Posts: 65389
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Embedded Icons copy feature -> upgrade.

Post by admin »

You can copy the file (as file system object) but not the image (as 32-bit ARGB bitmap).

eil
Posts: 1832
Joined: 13 Jan 2011 19:44

Re: Embedded Icons copy feature -> upgrade.

Post by eil »

Now i get curious: i use one of simple Nirsoft tools, open XY main EXE, select any dimension of icon, use Copy to clipboard = an it's properly passed into any image editor. Maybe "transparency" was a wrong wording in initial description, i simply meant usual PNG thing with "no background".
Yet i've met a some number of scripts(like power shell ones) that could extract in file or copy to clipboard, that's why thought it's not that of a big deal.
2024-11-15_215614.png
2024-11-15_215614.png (31.05 KiB) Viewed 3494 times
2024-11-15_215648.png
2024-11-15_215648.png (9.34 KiB) Viewed 3494 times
Win 7 SP1 x64 100% 1366x768|1900x1080

admin
Site Admin
Posts: 65389
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Embedded Icons copy feature -> upgrade.

Post by admin »

Hm, interesting. You would need a clipboard viewer to see how it's done. Maybe the slightly mysterious CF_DIBV5 format?

eil
Posts: 1832
Joined: 13 Jan 2011 19:44

Re: Embedded Icons copy feature -> upgrade.

Post by eil »

Have no clue since i'm not a developer.
I was hoping to find some command-line tool on GitHub to do same stuff i described in first post here, but for pity they always lack smth. But maybe these can give you some "examples", cause projects have different languages, yet still able to extract icon into PNG.

https://github.com/loilo/ico2png-cli (JavaScript)
https://github.com/kevinuulong/file-icon-extractor (JavaScript)
https://github.com/muflone/gextractwinicons (Python)
https://github.com/bertjohnson/ExtractIcon (C ,probably)
https://github.com/zmconnelly/windows-icons (Rust)
https://github.com/lonkaars/icon256 (C#) +base64 encode, so must somehow get first PNG in memory to encode
https://github.com/SkaceKamen/win-icon-extractor (JavaScript) +base64 encode
Win 7 SP1 x64 100% 1366x768|1900x1080

admin
Site Admin
Posts: 65389
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Embedded Icons copy feature -> upgrade.

Post by admin »

I currently have no time for the clipboard stuff (though I now believe it should be possible using format "Bitmap DIB"), but something good came out of some quick testing:

Code: Select all

    + SC savethumb: Now you can save an ICO file as PNG while preserving transparency.
      Example:
        savethumb(, "*_t", 24, , "png", 7:=-1); //save currently selected ICO as PNG

eil
Posts: 1832
Joined: 13 Jan 2011 19:44

Re: Embedded Icons copy feature -> upgrade.

Post by eil »

Example indeed works, png gets extracted, and i'm even surprised example was already in Help file.!
But there is a little flaw. As i presume it takes the best quality from icon and resizes it to stated size. This overlooks the option to extract native 16x icon, which is often much better quality/re-drawn than any resized variant. Is there maybe a way to select the dimension which to take for extraction.

Is there a way to adapt this for icon in EXE extraction?(currently it doesn't recognize EXE as valid source) Yet, since it anyways does some internal "re-creation" from icon, may it be base64 encoded along the way, instead of creating a file?
Win 7 SP1 x64 100% 1366x768|1900x1080

admin
Site Admin
Posts: 65389
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Embedded Icons copy feature -> upgrade.

Post by admin »

I have not even uploaded the new beta. :?

No, that's more complex.

eil
Posts: 1832
Joined: 13 Jan 2011 19:44

Re: Embedded Icons copy feature -> upgrade.

Post by eil »

admin wrote: 18 Nov 2024 17:43 I have not even uploaded the new beta. :?
Well, i tried example on 26.50.0300 and it already works(even Help file has very same example).
XYplorer - developing future.(c) [which even dev is not aware of :mrgreen: ]

But if you added smth even better, that's surely good. Shame about encode, hoped to use in-clipboard for that too. Or did you mean extracting from EXE is more complex?
Win 7 SP1 x64 100% 1366x768|1900x1080

Post Reply