Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Different sizing? #13

Closed
RixInGithub opened this issue Jun 26, 2023 · 4 comments
Closed

Different sizing? #13

RixInGithub opened this issue Jun 26, 2023 · 4 comments
Labels
question Further information is requested

Comments

@RixInGithub
Copy link

In a previous issue #11, I said this:

Ok, yeah, all the icons for system libraries got moved to a new location in Windows 10 1903: https://superuser.com/questions/1480268/icons-no-longer-in-imageres-dll-in-windows-10-1903-4kb-file

I'm not sure if the new DLLs actually embed a reference to the .mun files, or if the system implicitly looks up the right file based on the DLL name. If the latter is true, there's not much icoextract can do other than make a guess.

My version of the C:\Windows\SystemResources\imageres.dll.mun file starts off with the magic bytes of "MZ", typically an executable or a .DLL

And with my second edit, I said, that I needed a different size of the icon. I want the icon to be 48x48 pixels in size, and here's the snippet:

import icoextract as icns

ext = icns.IconExtractor(r"C:\Windows\SystemResources\imageres.dll.mun")
ext.export_icon("foldIcon.ico", num=3)
print("Icon extracted successfully.")

foldIcon.ico is currently 16x16 pixels in size, but I want it to be a 48x48 icon, to be as an PIL image. Can some help me?

@jlu5
Copy link
Owner

jlu5 commented Jun 27, 2023

This is working fine for me when looking at SystemResources on Windows 11.

.ico files are multi-image files, and each "group icon" will usually contain multiple sizes and bit depths. You'll definitely want to use a toolchain that's aware of this: for example, the Pillow library lets you extract specific sizes using the save() method: see https://pillow.readthedocs.io/en/stable/handbook/image-file-formats.html#ico

@jlu5 jlu5 added the question Further information is requested label Jun 27, 2023
@RixInGithub
Copy link
Author

This is working fine for me when looking at SystemResources on Windows 11.

.ico files are multi-image files, and each "group icon" will usually contain multiple sizes and bit depths. You'll definitely want to use a toolchain that's aware of this: for example, the Pillow library lets you extract specific sizes using the save() method: see https://pillow.readthedocs.io/en/stable/handbook/image-file-formats.html#ico

No, I meant the PIL part as if for the image to be an Image object.

@jlu5
Copy link
Owner

jlu5 commented Jun 29, 2023

Doe something like this work? This is how I do resizing in the exe-thumbnailer script, though I suppose the im.size = ... trick isn't mentioned in that doc page. I don't quite remember how I found out about this, perhaps it was just experimentation.

from icoextract import IconExtractor
from PIL import Image

extractor = IconExtractor('imageres.dll.mun')
data = extractor.get_icon(num=3)
im = Image.open(data)  # create a PIL image from the .ico in memory
im.size = (48, 48)
im.save("result.png", "PNG")

@RixInGithub
Copy link
Author

Doe something like this work? This is how I do resizing in the exe-thumbnailer script, though I suppose the im.size = ... trick isn't mentioned in that doc page. I don't quite remember how I found out about this, perhaps it was just experimentation.

from icoextract import IconExtractor
from PIL import Image

extractor = IconExtractor('imageres.dll.mun')
data = extractor.get_icon(num=3)
im = Image.open(data)  # create a PIL image from the .ico in memory
im.size = (48, 48)
im.save("result.png", "PNG")

WOW, thanks for the help! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants