Compare commits
11 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8467e6f6e3 |
||
|
|
698a963415 |
||
|
|
8d22ee87d0 | ||
|
|
507c780ab5 | ||
|
|
cf95bd28d8 | ||
|
|
fdfc5dd04e | ||
|
|
e02e236ebc | ||
|
|
b6971c5df6 | ||
|
|
3a053fe76a | ||
|
|
a7395cce2b | ||
|
|
045d06bdba |
|
|
@ -74,14 +74,14 @@ InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" ""
|
|||
ShowInstDetails show
|
||||
ShowUnInstDetails show
|
||||
|
||||
Section "Electrifycutable" SEC01
|
||||
Section "Electrify" SEC01
|
||||
SectionIn RO
|
||||
SetOutPath "$INSTDIR"
|
||||
SetOverwrite try
|
||||
File /r /x compressors "ElectrifyWin\"
|
||||
|
||||
CreateDirectory "$LocalAppData\Electrifycutable\Electrifycutable\files\compressors"
|
||||
SetOutPath "$LocalAppData\Electrifycutable\Electrifycutable\files\compressors"
|
||||
CreateDirectory "$LocalAppData\Electrify\Electrify\files\compressors"
|
||||
SetOutPath "$LocalAppData\Electrify\Electrify\files\compressors"
|
||||
File "ElectrifyWin\files\compressors\upx-win.exe"
|
||||
|
||||
; Shortcuts
|
||||
|
|
|
|||
|
|
@ -1,3 +1,8 @@
|
|||
NOTICE
|
||||
======
|
||||
|
||||
This app is unmaintained. I do not have the resources to work on it any longer and haven't for a long time. If anyone would like to sponsor this project or take up ownership from me, I'd be glad to do either.
|
||||
|
||||
Electrify
|
||||
==============
|
||||
|
||||
|
|
@ -7,7 +12,7 @@ Electrify
|
|||
What is it?
|
||||
-----------
|
||||
|
||||
From the creator of [Web2Executable](https://github.com/jyapayne/Electrifycutable) comes Electrify, another friendly command line and GUI application that can transform your Nodejs (or any other JS/HTML) app into a standalone executable. The difference is that it is now powered by [Electron](https://github.com/atom/electron) instead of NW.js. It can export to Mac OS X, Windows and Linux all from one platform, so no need to go out and buy expensive hardware.
|
||||
From the creator of [Web2Executable](https://github.com/jyapayne/Web2Executable) comes Electrify, another friendly command line and GUI application that can transform your Nodejs (or any other JS/HTML) app into a standalone executable. The difference is that it is now powered by [Electron](https://github.com/atom/electron) instead of NW.js. It can export to Mac OS X, Windows and Linux all from one platform, so no need to go out and buy expensive hardware.
|
||||
|
||||
It's powered by the very awesome project [Electron](https://github.com/atom/electron) and PySide, is open source, and is just dang awesome and easy to use.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,16 +1,15 @@
|
|||
|
||||
rm -rf ElectrifyLinux*.zip
|
||||
rm -rf ElectrifyLinux-CMD
|
||||
rm -rf build ElectrifyLinux*
|
||||
|
||||
VERSION=$(cat files/version.txt)
|
||||
|
||||
pyinstaller --onefile --hidden-import PIL.Jpeg2KImagePlugin --hidden-import pkg_resources --hidden-import PIL._imaging --hidden-import configobj --distpath ElectrifyLinux-CMD -n electrify-linux command_line.py
|
||||
pyinstaller --onefile --exclude-module PyQt5 --exclude-module PyQt4 --hidden-import PIL._imaging --hidden-import PIL.Jpeg2KImagePlugin --hidden-import pkg_resources --hidden-import PIL._imaging --hidden-import configobj --distpath ElectrifyLinux-CMD -n electrify-linux command_line.py
|
||||
cp -rf files ElectrifyLinux-CMD/files
|
||||
rm -rf ElectrifyLinux-CMD/files/downloads/*
|
||||
rm ElectrifyLinux-CMD/files/error.log ElectrifyLinux-CMD/files/last_project_path.txt ElectrifyLinux-CMD/files/recent_files.txt ElectrifyLinux-CMD/files/compressors/upx-mac ElectrifyLinux-CMD/files/compressors/upx-win.exe
|
||||
|
||||
rm -rf ElectrifyLinux
|
||||
pyinstaller -F --hidden-import PIL.Jpeg2KImagePlugin --hidden-import configobj --hidden-import PIL._imaging --hidden-import pkg_resources -n electrify --distpath ElectrifyLinux main.py
|
||||
pyinstaller -F --exclude-module PyQt5 --exclude-module PyQt4 --hidden-import PIL._imaging --hidden-import PIL.Jpeg2KImagePlugin --hidden-import configobj --hidden-import PIL._imaging --hidden-import pkg_resources -n electrify --distpath ElectrifyLinux main.py
|
||||
cp -rf files ElectrifyLinux/files
|
||||
rm -rf ElectrifyLinux/files/downloads/*
|
||||
rm ElectrifyLinux/files/error.log ElectrifyLinux/files/last_project_path.txt ElectrifyLinux/files/recent_files.txt ElectrifyLinux/files/compressors/upx-mac ElectrifyLinux/files/compressors/upx-win.exe
|
||||
|
|
|
|||
|
|
@ -7,28 +7,28 @@ rm -rf ElectrifyMac-CMD/files
|
|||
pyinstaller --hidden-import PIL.Jpeg2KImagePlugin --hidden-import configobj --hidden-import pkg_resources --distpath ElectrifyMac-CMD --onefile -n electrify-mac command_line.py
|
||||
cp -rf files ElectrifyMac-CMD/files/
|
||||
|
||||
rm -rf build dist Electrifycutable.app
|
||||
rm -rf build dist Electrify.app
|
||||
|
||||
#sudo python build_mac_setup.py py2app --iconfile icon.icns
|
||||
pyinstaller -w --hidden-import PIL.Jpeg2KImagePlugin --hidden-import PyQt4 --hidden-import PIL --hidden-import configobj --hidden-import pkg_resources --distpath ElectrifyMac --onefile -n Electrifycutable main.py
|
||||
pyinstaller -w --hidden-import PIL.Jpeg2KImagePlugin --hidden-import PyQt4 --hidden-import PIL --hidden-import configobj --hidden-import pkg_resources --distpath ElectrifyMac --onefile -n Electrify main.py
|
||||
|
||||
#sudo chown -R joey dist/Electrifycutable.app
|
||||
#sudo chown -R joey dist/Electrify.app
|
||||
#sudo chown -R joey dist/ build/
|
||||
#mv dist/Electrifycutable.app Electrifycutable.app
|
||||
#mv dist/Electrify.app Electrify.app
|
||||
|
||||
mv ElectrifyMac/Electrifycutable.app .
|
||||
mv ElectrifyMac/Electrify.app .
|
||||
|
||||
#rm -rf Electrifycutable.app/Contents/Frameworks/QtDesigner*
|
||||
#rm -rf Electrifycutable.app/Contents/Frameworks/QtXml*
|
||||
#rm -rf Electrifycutable.app/Contents/Frameworks/QtWebKit*
|
||||
#rm -rf Electrifycutable.app/Contents/Frameworks/QtScript*
|
||||
#rm -rf Electrify.app/Contents/Frameworks/QtDesigner*
|
||||
#rm -rf Electrify.app/Contents/Frameworks/QtXml*
|
||||
#rm -rf Electrify.app/Contents/Frameworks/QtWebKit*
|
||||
#rm -rf Electrify.app/Contents/Frameworks/QtScript*
|
||||
|
||||
cp icon.icns Electrifycutable.app/Contents/Resources/icon-windowed.icns
|
||||
cp -rf files Electrifycutable.app/Contents/MacOS/
|
||||
cp icon.icns Electrify.app/Contents/Resources/icon-windowed.icns
|
||||
cp -rf files Electrify.app/Contents/MacOS/
|
||||
|
||||
rm -rf build dist
|
||||
|
||||
/Applications/Keka.app/Contents/Resources/keka7z a -r ElectrifyMac-CMD.zip ElectrifyMac-CMD
|
||||
/Applications/Keka.app/Contents/Resources/keka7z a -r ElectrifyMac-${VERSION}.zip Electrifycutable.app
|
||||
/Applications/Keka.app/Contents/Resources/keka7z a -r ElectrifyMac-${VERSION}.zip Electrify.app
|
||||
|
||||
python upload_release.py
|
||||
python3.4 upload_release.py
|
||||
|
|
|
|||
|
|
@ -275,7 +275,7 @@ class CommandBase(object):
|
|||
self.setup_electron_versions()
|
||||
|
||||
def update_electron_versions(self, button):
|
||||
self.progress_text = 'Updating nw versions...'
|
||||
self.progress_text = 'Updating electron versions...'
|
||||
self.get_versions()
|
||||
self.progress_text = '\nDone.\n'
|
||||
|
||||
|
|
@ -685,14 +685,14 @@ class CommandBase(object):
|
|||
inject_start_file = utils.path_join(self.project_dir(),
|
||||
inject_start_file)
|
||||
|
||||
if os.path.exists(inject_start_file):
|
||||
if os.path.isfile(inject_start_file):
|
||||
inject_js_start = codecs.open(inject_start_file, encoding='utf-8').read()
|
||||
|
||||
inject_end_file = self.get_setting('inject_js_end').value
|
||||
inject_end_file = utils.path_join(self.project_dir(),
|
||||
inject_end_file)
|
||||
|
||||
if os.path.exists(inject_end_file):
|
||||
if os.path.isfile(inject_end_file):
|
||||
inject_js_end = codecs.open(inject_end_file, encoding='utf-8').read()
|
||||
|
||||
main_html = self.get_setting('main_html')
|
||||
|
|
@ -1316,10 +1316,6 @@ def main():
|
|||
if args.app_name is None:
|
||||
args.app_name = command_base.project_name()
|
||||
|
||||
if args.name is not None:
|
||||
setting = command_base.get_setting('name')
|
||||
args.name = setting.filter_name(args.name if not callable(args.name) else args.name())
|
||||
|
||||
command_base._project_name = args.app_name if not callable(args.app_name) else args.app_name()
|
||||
|
||||
if not args.title:
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 16 KiB |
|
|
@ -19,7 +19,7 @@
|
|||
xml:space="preserve"
|
||||
inkscape:version="0.91+devel r"
|
||||
sodipodi:docname="icon.svg"
|
||||
inkscape:export-filename="/home/joey/Projects/Electrify/files/images/icon.png"
|
||||
inkscape:export-filename="/home/joey/Projects/Electrify/icon.png"
|
||||
inkscape:export-xdpi="1536.9606"
|
||||
inkscape:export-ydpi="1536.9606"><metadata
|
||||
id="metadata47"><rdf:RDF><cc:Work
|
||||
|
|
@ -27,6 +27,14 @@
|
|||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title /></cc:Work></rdf:RDF></metadata><defs
|
||||
id="defs45"><linearGradient
|
||||
inkscape:collect="always"
|
||||
id="linearGradient4284"><stop
|
||||
style="stop-color:#000000;stop-opacity:1;"
|
||||
offset="0"
|
||||
id="stop4280" /><stop
|
||||
style="stop-color:#000000;stop-opacity:0;"
|
||||
offset="1"
|
||||
id="stop4282" /></linearGradient><linearGradient
|
||||
inkscape:collect="always"
|
||||
id="linearGradient4291"><stop
|
||||
style="stop-color:#000000;stop-opacity:1;"
|
||||
offset="0"
|
||||
|
|
@ -74,7 +82,22 @@
|
|||
x1="9.9701958"
|
||||
y1="-0.75106245"
|
||||
x2="7.6029081"
|
||||
y2="12.573604" /></defs><sodipodi:namedview
|
||||
y2="12.573604" /><linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient4284"
|
||||
id="linearGradient4286"
|
||||
x1="15.023907"
|
||||
y1="13.151308"
|
||||
x2="1.1221439"
|
||||
y2="-1.7265023"
|
||||
gradientUnits="userSpaceOnUse" /><mask
|
||||
maskUnits="userSpaceOnUse"
|
||||
id="mask4292"><path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path4294"
|
||||
d="M 14.551335,2.2174564 H 1.4414962 c -0.55716106,0 -1.00932234,0.4549991 -1.00932234,1.015944 v 9.3118736 c 0,0.561891 0.45216128,1.015944 1.00932234,1.015944 h 5.0286389 c 0.3482015,-0.002 2.656938,0.0011 3.0478318,0 H 14.55039 c 0.556215,0 1.00743,-0.454053 1.00743,-1.015944 V 3.2334004 c 0.0019,-0.5609449 -0.450269,-1.015944 -1.006485,-1.015944 z m -0.07284,9.6959266 H 1.513388 V 3.2977246 h 12.966056 z"
|
||||
style="fill:#b7b7b7;fill-opacity:1;stroke:none;stroke-width:0.18918882;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
sodipodi:nodetypes="sssssccsscsccccc" /></mask></defs><sodipodi:namedview
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1"
|
||||
|
|
@ -87,11 +110,11 @@
|
|||
inkscape:window-height="847"
|
||||
id="namedview43"
|
||||
showgrid="false"
|
||||
inkscape:zoom="19.391266"
|
||||
inkscape:cx="14.357018"
|
||||
inkscape:cy="-1.9941546"
|
||||
inkscape:window-x="2026"
|
||||
inkscape:window-y="191"
|
||||
inkscape:zoom="13.711696"
|
||||
inkscape:cx="6.5263324"
|
||||
inkscape:cy="5.4529621"
|
||||
inkscape:window-x="2029"
|
||||
inkscape:window-y="167"
|
||||
inkscape:window-maximized="0"
|
||||
inkscape:current-layer="Capa_1" /><g
|
||||
id="g13" /><g
|
||||
|
|
@ -129,21 +152,26 @@
|
|||
id="path9"
|
||||
d="M 10.175,18.56 C 8.516,18.56 6.97,18.084 5.651,17.273 6.838,17.285 4.768,15.467 6.194,15.188 7.69,14.894 8.32,13.183 7.841,13.209 7.363,13.234 6.453,12.962 5.813,12.158 5.172,11.348 4.611,11.533 3.95,11.66 3.372,11.774 2.66,13.446 2.483,13.885 2.033,13.023 1.728,12.076 1.59,11.075 2.324,10.691 3.522,10.045 3.955,9.688 4.593,9.159 3.742,8.945 3.637,8.626 c -0.104,-0.319 0,-1.062 0,-1.8 C 3.637,6.081 5.123,6.081 5.65,5.34 6.029,4.811 5.335,3.644 4.902,3.012 6.365,1.886 8.191,1.209 10.175,1.209 c 0.526,0 1.039,0.055 1.54,0.145 0.147,0.914 0.453,2.171 1.044,2.499 0.957,0.53 2.115,1.697 2.543,1.907 0.426,0.212 0.953,2.018 0.849,2.76 -0.075,0.524 -0.725,1.101 -0.991,1.656 l 4.42,2.754 C 19.892,11.97 20.064,10.949 20.064,9.886 20.064,4.434 15.626,0 10.176,0 4.723,0 0.288,4.434 0.288,9.886 c 0,5.453 4.435,9.889 9.888,9.889 0.207,0 0.409,-0.019 0.613,-0.031 L 10.558,18.54 c -0.128,0.006 -0.254,0.02 -0.383,0.02 z m 8.569,-7.394 C 18.557,10.424 18.195,9.708 17.425,9.155 16.898,8.783 16.468,7.141 16.788,6.609 c 0.191,-0.317 0.688,-0.596 1.054,-0.77 0.641,1.209 1.007,2.585 1.007,4.047 0,0.436 -0.043,0.861 -0.105,1.28 z"
|
||||
style="fill:#13cf00;fill-opacity:1;stroke:none;stroke-opacity:1"
|
||||
inkscape:connector-curvature="0" /></g></g></g><g
|
||||
id="g5"
|
||||
style="fill:#b7b7b7;fill-opacity:1;stroke:none;stroke-width:0.2;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
transform="matrix(0.9459441,0,0,0.9459441,0.43217386,1.5969171)"><path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path7"
|
||||
d="M 14.926,0.656 H 1.067 C 0.478,0.656 0,1.137 0,1.73 v 9.844 c 0,0.594 0.478,1.074 1.067,1.074 h 5.316 c 0.3680995,-0.0021 2.8087686,0.0012 3.222,0 h 5.32 c 0.588,0 1.065,-0.48 1.065,-1.074 V 1.73 C 15.992,1.137 15.514,0.656 14.926,0.656 Z m -0.077,10.25 H 1.143 V 1.798 H 14.85 Z"
|
||||
style="fill:#b7b7b7;fill-opacity:1;stroke:none;stroke-width:0.2;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
sodipodi:nodetypes="sssssccsscsccccc" /></g><rect
|
||||
inkscape:connector-curvature="0" /></g></g></g><path
|
||||
sodipodi:nodetypes="sssssccsscsccccc"
|
||||
style="fill:#b7b7b7;fill-opacity:1;stroke:none;stroke-width:0.18918882;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="M 14.551335,2.2174564 H 1.4414962 c -0.55716106,0 -1.00932234,0.4549991 -1.00932234,1.015944 v 9.3118736 c 0,0.561891 0.45216128,1.015944 1.00932234,1.015944 h 5.0286389 c 0.3482015,-0.002 2.656938,0.0011 3.0478318,0 H 14.55039 c 0.556215,0 1.00743,-0.454053 1.00743,-1.015944 V 3.2334004 c 0.0019,-0.5609449 -0.450269,-1.015944 -1.006485,-1.015944 z m -0.07284,9.6959266 H 1.513388 V 3.2977246 h 12.966056 z"
|
||||
id="path7"
|
||||
inkscape:connector-curvature="0" /><path
|
||||
style="opacity:0.20499998;fill:url(#linearGradient4286);fill-opacity:1;stroke:none;stroke-width:0.51011908;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:0.51011912, 1.53035736000000000;stroke-dashoffset:0;stroke-opacity:1"
|
||||
inkscape:transform-center-x="2.5200128"
|
||||
inkscape:transform-center-y="-1.4405186"
|
||||
d="M -10.647609,10.384715 14.900692,-9.2342355 19.865267,21.534206 Z"
|
||||
id="path4251"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="cccc"
|
||||
mask="url(#mask4292)" /><rect
|
||||
style="color:#000000;display:inline;overflow:visible;visibility:visible;opacity:1;fill:#001118;fill-opacity:1;stroke:none;stroke-width:0.34977314;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;enable-background:accumulate"
|
||||
id="rect4228"
|
||||
width="13.186693"
|
||||
height="9.248354"
|
||||
x="1.3780756"
|
||||
y="3.2113624"
|
||||
x="1.2927508"
|
||||
y="3.2977245"
|
||||
ry="0" /><path
|
||||
style="opacity:0.20499998;fill:url(#linearGradient4315);fill-opacity:1;stroke:none;stroke-width:0.37146091;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
inkscape:transform-center-x="-1.526323"
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 28 KiB |
|
|
@ -408,12 +408,6 @@ linux_64_dir_prefix = 'electron-v{}-linux-x64'
|
|||
url='%(base_url)s%(win_64_dir_prefix)s.zip'
|
||||
binary_location='electron.exe'
|
||||
|
||||
[[mac-x32]]
|
||||
default_value=False
|
||||
type='check'
|
||||
url='%(base_url)s%(mac_32_dir_prefix)s.zip'
|
||||
binary_location='Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/Current/Electron Framework'
|
||||
|
||||
[[mac-x64]]
|
||||
default_value=False
|
||||
type='check'
|
||||
|
|
@ -470,7 +464,7 @@ linux_64_dir_prefix = 'electron-v{}-linux-x64'
|
|||
'webaudio', 'plugins', 'experimental_features', 'experimental_canvas_features',
|
||||
'direct_write']"""
|
||||
|
||||
export_setting_order = """['windows-x32', 'windows-x64', 'mac-x32', 'mac-x64', 'linux-x64', 'linux-x32']"""
|
||||
export_setting_order = """['windows-x32', 'windows-x64', 'mac-x64', 'linux-x64', 'linux-x32']"""
|
||||
compression_setting_order = """['electron_compression_level']"""
|
||||
|
||||
download_setting_order = """['electron_version', 'download_dir',
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
v0.4.1b
|
||||
v0.4.2b
|
||||
|
|
|
|||
57
icns_info.py
|
|
@ -581,7 +581,7 @@ def get_mask_type_for_icon_type(icon_type):
|
|||
|
||||
def to_bytes(n, length, endianess='big'):
|
||||
h = '%x' % n
|
||||
s = ('0'*(len(h) % 2) + h).zfill(length*2).decode('hex')
|
||||
s = bytes.fromhex(('0'*(len(h) % 2) + h).zfill(length*2))
|
||||
return s if endianess == 'big' else s[::-1]
|
||||
|
||||
|
||||
|
|
@ -601,7 +601,7 @@ def type_to_str(type):
|
|||
s.append(type >> 8 & 0xff)
|
||||
s.append(type & 0xff)
|
||||
s.append(0)
|
||||
return str(s)
|
||||
return bytes(s)
|
||||
|
||||
class Printable(object):
|
||||
def _attrs(self):
|
||||
|
|
@ -953,8 +953,8 @@ class ICNSInfo(Printable):
|
|||
print('Unable to parse icon type {}'.format(type_to_str(type)))
|
||||
icon_info.iconType = ICNS_NULL_TYPE
|
||||
|
||||
icon_info.iconRawDataSize = icon_info.iconSize.height * icon_info.iconSize.width * icon_info.iconBitDepth/ICNS_BYTE_BITS
|
||||
icon_info.data = bytearray(icon_info.iconRawDataSize)
|
||||
icon_info.iconRawDataSize = int(icon_info.iconSize.height * icon_info.iconSize.width * icon_info.iconBitDepth/ICNS_BYTE_BITS)
|
||||
icon_info.data = bytearray(int(icon_info.iconRawDataSize))
|
||||
|
||||
return icon_info
|
||||
|
||||
|
|
@ -999,12 +999,12 @@ class ICNSHeader(Structure):
|
|||
|
||||
icns_info = ICNSInfo()
|
||||
icns_info.isImage = 1
|
||||
icns_info.iconSize.width = icon_size
|
||||
icns_info.iconSize.height = icon_size
|
||||
icns_info.iconSize.width = int(icon_size)
|
||||
icns_info.iconSize.height = int(icon_size)
|
||||
icns_info.iconBitDepth = bpp
|
||||
icns_info.iconChannels = 4 if bpp == 32 else 1
|
||||
icns_info.iconPixelDepth = bpp / icns_info.iconChannels
|
||||
icns_info.iconRawDataSize = width * height * 4
|
||||
icns_info.iconPixelDepth = int(bpp / icns_info.iconChannels)
|
||||
icns_info.iconRawDataSize = int(width * height * 4)
|
||||
icns_info.data = bytearray(list(data))
|
||||
|
||||
icon_type = icns_info.get_image_type()
|
||||
|
|
@ -1097,33 +1097,37 @@ class ICNSElement(Structure):
|
|||
|
||||
width, height, png_data, stats_dict = png_file.read_flat()
|
||||
|
||||
im = Image.frombytes('RGBA', [width, height], bytes(png_data))
|
||||
output = BytesIO()
|
||||
im.save(output, format='PNG')
|
||||
|
||||
bpp = stats_dict['bitdepth'] * 4
|
||||
|
||||
icns_info = ICNSInfo()
|
||||
icns_info.isImage = 1
|
||||
icns_info.iconSize.width = width
|
||||
icns_info.iconSize.height = height
|
||||
icns_info.iconSize.width = int(width)
|
||||
icns_info.iconSize.height = int(height)
|
||||
icns_info.iconBitDepth = bpp
|
||||
icns_info.iconChannels = 4 if bpp == 32 else 1
|
||||
icns_info.iconPixelDepth = bpp / icns_info.iconChannels
|
||||
icns_info.iconRawDataSize = width * height * 4
|
||||
icns_info.data = bytearray(list(png_data))
|
||||
icns_info.iconPixelDepth = int(bpp / icns_info.iconChannels)
|
||||
icns_info.iconRawDataSize = int(width * height * 4)
|
||||
icns_info.data = bytes(output.getvalue())
|
||||
else:
|
||||
image = Image.open(BytesIO(data))
|
||||
mode_to_bpp = {'1':1, 'L':8, 'P':8, 'RGB':24, 'RGBA':32, 'CMYK':32, 'YCbCr':24, 'I':32, 'F':32}
|
||||
output = BytesIO()
|
||||
image.save(output, format='PNG')
|
||||
bpp = mode_to_bpp[image.mode]
|
||||
png_data = bytearray(output.getvalue())
|
||||
png_data = bytes(output.getvalue())
|
||||
|
||||
icns_info = ICNSInfo()
|
||||
icns_info.isImage = 1
|
||||
icns_info.iconSize.width = image.size[0]
|
||||
icns_info.iconSize.height = image.size[1]
|
||||
icns_info.iconSize.width = int(image.size[0])
|
||||
icns_info.iconSize.height = int(image.size[1])
|
||||
icns_info.iconBitDepth = bpp
|
||||
icns_info.iconChannels = 4 if bpp == 32 else 1
|
||||
icns_info.iconPixelDepth = bpp / icns_info.iconChannels
|
||||
icns_info.iconRawDataSize = image.size[0] * image.size[1] * 4
|
||||
icns_info.iconPixelDepth = int(bpp / icns_info.iconChannels)
|
||||
icns_info.iconRawDataSize = int(image.size[0] * image.size[1] * 4)
|
||||
icns_info.data = png_data
|
||||
|
||||
else:
|
||||
|
|
@ -1173,7 +1177,7 @@ class ICNSElement(Structure):
|
|||
data_pos = data_count * icon_data_row_size
|
||||
icns_info.data[data_pos:data_pos+icon_data_row_size] = data[data_pos:data_pos+icon_data_row_size]
|
||||
data_count += 1
|
||||
|
||||
|
||||
return icns_info
|
||||
|
||||
def get_mask(self):
|
||||
|
|
@ -1185,7 +1189,7 @@ class ICNSElement(Structure):
|
|||
icns_info = ICNSInfo.from_type(mask_type)
|
||||
mask_bit_depth = icns_info.iconSize.width * icns_info.iconSize.height
|
||||
mask_data_size = icns_info.iconRawDataSize
|
||||
mask_data_row_size = icns_info.iconSize.width * mask_bit_depth / ICNS_BYTE_BITS
|
||||
mask_data_row_size = int(icns_info.iconSize.width * mask_bit_depth / ICNS_BYTE_BITS)
|
||||
|
||||
if mask_type in [ICNS_128x128_8BIT_MASK,
|
||||
ICNS_48x48_8BIT_MASK,
|
||||
|
|
@ -1193,7 +1197,7 @@ class ICNSElement(Structure):
|
|||
ICNS_16x16_8BIT_MASK]:
|
||||
data_count = 0
|
||||
while data_count < icns_info.iconSize.height:
|
||||
data_pos = data_count * mask_data_row_size
|
||||
data_pos = int(data_count * mask_data_row_size)
|
||||
icns_info.data[data_pos:data_pos+mask_data_row_size] = data[data_pos:data_pos+mask_data_row_size]
|
||||
data_count += 1
|
||||
|
||||
|
|
@ -1280,7 +1284,7 @@ def get_image_with_mask(icns_data, element_type):
|
|||
new_data_size = new_block_size * icns_image.iconSize.height
|
||||
|
||||
old_data = icns_image.data
|
||||
new_data = bytearray(new_data_size)
|
||||
new_data = bytearray(int(new_data_size))
|
||||
|
||||
data_count = 0
|
||||
|
||||
|
|
@ -1329,7 +1333,7 @@ def get_image_with_mask(icns_data, element_type):
|
|||
|
||||
icns_image.iconPixelDepth = 8
|
||||
icns_image.iconChannels = 4
|
||||
icns_image.iconRawDataSize = new_data_size
|
||||
icns_image.iconRawDataSize = int(new_data_size)
|
||||
icns_image.data = new_data
|
||||
|
||||
if mask_type in [ICNS_128x128_8BIT_MASK,
|
||||
|
|
@ -1356,10 +1360,11 @@ def get_image_with_mask(icns_data, element_type):
|
|||
color_index = 0xFF if (data_value & 0x80) else 0x00
|
||||
data_value = data_value << 1
|
||||
icns_image.data[pixel_id*4+3] = color_index
|
||||
im = Image.frombytes('RGBA', [icns_image.iconSize.width,icns_image.iconSize.height],str(icns_image.data))
|
||||
im = Image.frombytes('RGBA', [icns_image.iconSize.width,icns_image.iconSize.height], bytes(icns_image.data))
|
||||
#print(icns_image.data)
|
||||
output = BytesIO()
|
||||
im.save(output, format='PNG')
|
||||
icns_image.data = bytearray(output.getvalue())
|
||||
icns_image.data = bytes(output.getvalue())
|
||||
|
||||
return icns_image
|
||||
|
||||
|
|
@ -1398,7 +1403,7 @@ def extract_icons(all_icns_data):
|
|||
image_count += 1
|
||||
|
||||
image_data = get_image_with_mask(icns_data, element.TypeID)
|
||||
image_data.data = str(image_data.data)
|
||||
image_data.data = bytes(image_data.data)
|
||||
data.append(image_data)
|
||||
|
||||
offset += element.Size
|
||||
|
|
|
|||
BIN
icon.icns
BIN
icon.ico
|
Before Width: | Height: | Size: 264 KiB After Width: | Height: | Size: 264 KiB |
BIN
icon.png
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 16 KiB |
3
main.py
|
|
@ -863,7 +863,8 @@ class MainWindow(QtGui.QMainWindow, CommandBase):
|
|||
if icon_path.endswith('.icns'):
|
||||
pngs = pngs_from_icns(icon_path)
|
||||
if pngs:
|
||||
image = QtGui.QImage.fromData(QtCore.QByteArray(pngs[-1].data), 'PNG')
|
||||
ba = QtCore.QByteArray(pngs[-1].data)
|
||||
image = QtGui.QImage.fromData(ba, 'PNG')
|
||||
else:
|
||||
return
|
||||
else:
|
||||
|
|
|
|||