from PIL import Image
from tkinter import Tk, filedialog, Button, Label
def merge_images_to_pdf(image_list, output_pdf_path):
# Open images and convert them to RGB mode (required for PDF)
images = [Image.open(img).convert('RGB') for img in image_list]
# Save the first image and append the rest to it
images[0].save(output_pdf_path, save_all=True, append_images=images[1:])
def choose_files():
# Open file dialog to select multiple image files
image_files = filedialog.askopenfilenames(
title="Select JPG files to merge",
filetypes=[("JPEG files", "*.jpg *.jpeg"), ("All files", "*.*")]
)
if image_files:
# Define the output file path
output_pdf = filedialog.asksaveasfilename(
defaultextension=".pdf",
filetypes=[("PDF files", "*.pdf"), ("All files", "*.*")],
title="Save Merged PDF as"
)
if output_pdf:
# Merge selected images into a single PDF
merge_images_to_pdf(image_files, output_pdf)
result_label.config(text=f"Merged PDF saved as {output_pdf}")
else:
result_label.config(text="No output file specified. PDF not saved.")
else:
result_label.config(text="No images selected.")
if __name__ == "__main__":
# Initialize the root Tkinter window
root = Tk()
root.title("Image to PDF Merger")
# Create a "Choose Files" button and attach the choose_files function
choose_button = Button(root, text="Choose Files", command=choose_files)
choose_button.pack(pady=20)
# Create a label to display results
result_label = Label(root, text="")
result_label.pack(pady=20)
# Run the Tkinter event loop
root.mainloop() ChatGPT ile yazdırmış olduğum Python kodunu EXE'ye Dönüştürme
8
●262
- 24-08-2024, 03:08:50Merhaba. Yazdırmış olduğum kodu PyInstaller ile .exe dosyasına dönüştürdüm aslında ama dosyada fazla kod yazılmamasına rağmen 29.1 MB ve biraz yavaş açılıyor. Bunu normal görmüyorum aslında. Bu sorunu nasıl çözebilirim?
- 24-08-2024, 03:11:49https://pypi.org/project/auto-py-to-exe/ ile kolayca halledebilirsiniz
- 24-08-2024, 03:14:33Hocam mesele hall etmek değil. Dosya boyutu yüksek oluyor ve dosya yavaş açılıyor. Bunu biliyorum teşekkürler.Centifolia adlı üyeden alıntı: mesajı görüntüle
- 24-08-2024, 03:15:20Şu komutu biliyorum hocam mesele o da değil. Console'u da gizliyorum hatta ama mesela dosya boyutu yüksek oluyor ve yavaş açılıyor.Micron adlı üyeden alıntı: mesajı görüntüle
- 24-08-2024, 03:16:42one file kullanmak daha çok yavaşlatacaktırrufiqcavadov adlı üyeden alıntı: mesajı görüntüle
- 24-08-2024, 03:22:31Çünkü PIL ve TKInter paketleriyle birlikte paketliyor .exe dosyasını onun için oldukça büyük. --onefile yerine --onedir paketlemeyi denerseniz sanırım daha olumlu sonuç alırsınız
- 24-08-2024, 18:32:32Böyle de olunca hocam yine yavaş açılıyor ve ayrıca dosya ile birlikte mi göndermem gerekiyor başka birisine örneğin çalıştırması için bilgisayarında?CihanAksoy adlı üyeden alıntı: mesajı görüntüle
- 26-08-2024, 10:01:43
- "pyinstaller --onefile --exclude-module=tkinter --exclude-module=numpy script.py" Tercih edilen kütüphaneleri dışlayabilirsin.
- "pyinstaller --onefile --upx-dir=C:upx script.py" UPX (Ultimate Packer for eXecutables ) kullanarak dosyanızı sıkıştırabilirsiniz.
Veya : Nuitka kütüphanesini tercih edebilirsiniz.