Skip to content

Commit c76ff77

Browse files
committed
Add ImageToWEBP
1 parent 23ece0e commit c76ff77

File tree

2 files changed

+54
-6
lines changed

2 files changed

+54
-6
lines changed

.github/workflows/build.yml

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,33 @@ jobs:
2424
python -m pip install --upgrade pip
2525
if (Test-Path requirements.txt) { pip install -r requirements.txt }
2626
27-
- name: Build executable
27+
- name: Build MapArtsMerger executable
2828
run: pyinstaller --onefile --windowed --icon=icon.ico MapArtsMerger.py
2929

30-
- name: Upload artifact
30+
- name: Build ImageToWEBP executable
31+
run: pyinstaller --onefile --windowed --icon=icon.ico ImageToWEBP.py
32+
33+
- name: Upload MapArtsMerger artifact
3134
uses: actions/upload-artifact@v4
3235
with:
33-
name: built-app
36+
name: MapArtsMerger
3437
path: dist/MapArtsMerger.exe
3538

39+
- name: Upload ImageToWEBP artifact
40+
uses: actions/upload-artifact@v4
41+
with:
42+
name: ImageToWEBP
43+
path: dist/ImageToWEBP.exe
44+
3645
- name: Release artifact
3746
if: github.event_name == 'push'
3847
uses: softprops/action-gh-release@v2
3948
with:
40-
files: dist/MapArtsMerger.exe
49+
files: |
50+
dist/MapArtsMerger.exe
51+
dist/ImageToWEBP.exe
4152
tag_name: latest
4253
name: Latest Release
43-
body: "Automated release of the latest version."
54+
body: "Automated release of the latest versions of MapArtsMerger and ImageToWEBP."
4455
env:
45-
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
56+
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}

ImageToWEBP.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import os
2+
import tkinter as tk
3+
from tkinter import filedialog, messagebox
4+
from PIL import Image
5+
6+
7+
def convert_to_webp():
8+
file_paths = filedialog.askopenfilenames(title="Select image files",
9+
filetypes=[("Image files", "*.png;*.jpg;*.jpeg;*.bmp;*.tiff")])
10+
11+
if not file_paths:
12+
return
13+
14+
save_dir = filedialog.askdirectory(title="Select destination folder")
15+
if not save_dir:
16+
return
17+
18+
for file_path in file_paths:
19+
try:
20+
img = Image.open(file_path)
21+
file_name = os.path.splitext(os.path.basename(file_path))[0] + ".webp"
22+
save_path = os.path.join(save_dir, file_name)
23+
img.save(save_path, "WEBP", lossless=True)
24+
except Exception as e:
25+
messagebox.showerror("Error", f"Failed to convert {file_path}: {e}")
26+
27+
messagebox.showinfo("Success", "All images have been converted to WebP (lossless).")
28+
29+
30+
root = tk.Tk()
31+
root.title("Image to WebP Converter")
32+
root.geometry("200x100")
33+
34+
btn_select = tk.Button(root, text="Select Images & Convert", command=convert_to_webp, padx=10, pady=5)
35+
btn_select.pack(pady=20)
36+
37+
root.mainloop()

0 commit comments

Comments
 (0)