Page 1 of 2

Embedded Icons copy feature -> upgrade.

Posted: 13 Nov 2024 18:49
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.

Re: Embedded Icons copy feature -> upgrade.

Posted: 13 Nov 2024 20:14
by admin
I tried this years ago but it was too hard / not worth the pain.

Re: Embedded Icons copy feature -> upgrade.

Posted: 13 Nov 2024 21:10
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)

Re: Embedded Icons copy feature -> upgrade.

Posted: 13 Nov 2024 21:28
by admin
Icofx works great.

Re: Embedded Icons copy feature -> upgrade.

Posted: 14 Nov 2024 11:52
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.

Re: Embedded Icons copy feature -> upgrade.

Posted: 14 Nov 2024 11:55
by admin
AFAIK the clipboard does not support transparency data anyway, only 24-bit bitmaps.

Re: Embedded Icons copy feature -> upgrade.

Posted: 14 Nov 2024 23:27
by eil
Hm, but PNG has transparency and those can be copied to clipboard.. or is that smth else?(not transparency)

Re: Embedded Icons copy feature -> upgrade.

Posted: 15 Nov 2024 09:48
by admin
You can copy the file (as file system object) but not the image (as 32-bit ARGB bitmap).

Re: Embedded Icons copy feature -> upgrade.

Posted: 15 Nov 2024 19:33
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 3496 times
2024-11-15_215648.png
2024-11-15_215648.png (9.34 KiB) Viewed 3496 times

Re: Embedded Icons copy feature -> upgrade.

Posted: 15 Nov 2024 20:27
by admin
Hm, interesting. You would need a clipboard viewer to see how it's done. Maybe the slightly mysterious CF_DIBV5 format?

Re: Embedded Icons copy feature -> upgrade.

Posted: 18 Nov 2024 00:07
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

Re: Embedded Icons copy feature -> upgrade.

Posted: 18 Nov 2024 11:42
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

Re: Embedded Icons copy feature -> upgrade.

Posted: 18 Nov 2024 17:37
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?

Re: Embedded Icons copy feature -> upgrade.

Posted: 18 Nov 2024 17:43
by admin
I have not even uploaded the new beta. :?

No, that's more complex.

Re: Embedded Icons copy feature -> upgrade.

Posted: 18 Nov 2024 17:55
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?