icoextract
Windows executable icon extractor.
For help on icoextract's frontend scripts, see icoextract --help and icolist --help.
Using icoextract as a library
from icoextract import IconExtractor, IconExtractorError
try:
extractor = IconExtractor('/path/to/your.exe')
# Export the first group icon to a .ico file
extractor.export_icon('/path/to/your.ico', num=0)
# Or read the .ico into a buffer, to pass it into other code
data = extractor.get_icon(num=0)
from PIL import Image
im = Image.open(data)
# ... manipulate a copy of the icon
# In icoextract 0.2.0+, you can also extract icons by resource ID
extractor.export_icon('/path/to/your.ico', resource_id=1234)
except IconExtractorError:
# No icons available, or the icon resource is malformed
pass
def
IconExtractor( filename: str | None = None, data: bytearray | mmap.mmap | None = None, exe_type: ExecutableType = <ExecutableType.AUTO: 0>) -> icoextract.base_extractor.BaseIconExtractor:
IconExtractor factory function.
When exe_type is set to AUTO, this will return an icoextract.pe_extractor.PEIconExtractor
for Win32/Win64 PE executables and an icoextract.ne_extractor.NEIconExtractor for Win16 NE
executables.
class
IconExtractorError(builtins.Exception):
Superclass for exceptions raised by IconExtractor.
Exception raised when extracting an icon index or resource ID that does not exist.
Exception raised when the input program has no icon resources.
Exception raised when the input program has an invalid icon resource.
Exception raised when the executable type is invalid or not supported.
class
ExecutableType(enum.Enum):
Enum for supported executable formats.
AUTO =
<ExecutableType.AUTO: 0>
PE =
<ExecutableType.PE: 1>
NE =
<ExecutableType.NE: 2>