Skip to content

Commit 287666a

Browse files
committed
new icon from png tool and changes to sak tool
1 parent 7065b76 commit 287666a

File tree

7 files changed

+59
-2
lines changed

7 files changed

+59
-2
lines changed

PNG to Icons with GUI/png2icon.py

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import sys
2+
import os
3+
from PySide6.QtWidgets import QApplication, QWidget, QVBoxLayout, QPushButton, QFileDialog, QMessageBox
4+
from PIL import Image
5+
6+
class IconConverterApp(QWidget):
7+
def __init__(self):
8+
super().__init__()
9+
self.setWindowTitle("PNG to Icon Converter")
10+
self.setGeometry(200, 200, 300, 120)
11+
12+
layout = QVBoxLayout()
13+
self.button = QPushButton("Select PNG and Convert")
14+
self.button.clicked.connect(self.convert_icon)
15+
layout.addWidget(self.button)
16+
17+
self.setLayout(layout)
18+
19+
def convert_icon(self):
20+
# Step 1: Select PNG file
21+
png_file, _ = QFileDialog.getOpenFileName(self, "Select PNG File", "", "PNG Files (*.png)")
22+
if not png_file:
23+
return
24+
25+
# Step 2: Ask where to save icons
26+
save_dir = QFileDialog.getExistingDirectory(self, "Select Save Directory")
27+
if not save_dir:
28+
return
29+
30+
try:
31+
img = Image.open(png_file).convert("RGBA")
32+
33+
# Windows ICO
34+
ico_path = os.path.join(save_dir, "icon.ico")
35+
img.save(ico_path, format="ICO", sizes=[(16,16), (32,32), (48,48), (256,256)])
36+
37+
# macOS ICNS
38+
icns_path = os.path.join(save_dir, "icon.icns")
39+
img.save(icns_path, format="ICNS")
40+
41+
# Linux PNG sizes
42+
linux_sizes = [16, 24, 32, 48, 64, 128, 256, 512]
43+
linux_dir = os.path.join(save_dir, "linux_icons")
44+
os.makedirs(linux_dir, exist_ok=True)
45+
for size in linux_sizes:
46+
resized = img.resize((size, size), Image.LANCZOS)
47+
resized.save(os.path.join(linux_dir, f"icon_{size}x{size}.png"))
48+
49+
QMessageBox.information(self, "Success", f"Icons saved in:\n{save_dir}")
50+
51+
except Exception as e:
52+
QMessageBox.critical(self, "Error", str(e))
53+
54+
if __name__ == "__main__":
55+
app = QApplication(sys.argv)
56+
window = IconConverterApp()
57+
window.show()
58+
sys.exit(app.exec())
File renamed without changes.

SAK Utility/icon.icns

107 KB
Binary file not shown.

SAK Utility/icon.ico

8.59 KB
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
PySide6
22
pywin32; platform_system == "Windows"
3-
plistlib
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
@echo off
22
REM Run the Python script using the default Python interpreter
3-
python "%~dp0windows_backup.py"
3+
python "%~dp0sak_utility.py"
44
pause

0 commit comments

Comments
 (0)