Skip to content

Commit f867680

Browse files
author
Landon Perkins (FROM PROSSER)
authored
Add files via upload
1 parent 14639e3 commit f867680

1 file changed

Lines changed: 338 additions & 4 deletions

File tree

main.py

Lines changed: 338 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
from tkinter import *
2+
from tkinter import filedialog
23
from PIL import ImageTk, Image, ImageFilter
34
import pygame
45
import random
56
import os
7+
import webbrowser
68

79
root = Tk()
810
root.title('Image Slideshow Program')
@@ -225,10 +227,333 @@ def sharpen():
225227
os.remove(str(randomname3) + ".png")
226228

227229

230+
def smoothen():
231+
randomname1 = random.randint(1, 10000)
232+
randomname2 = random.randint(1, 10000)
233+
randomname3 = randomname1 + randomname2
234+
if counter == 0:
235+
global im1pil
236+
global im1tk
237+
im1pil.save(str(randomname3) + ".png")
238+
im1pil = Image.open(str(randomname3) + ".png")
239+
im1pil = im1pil.convert('RGB')
240+
im1pil = im1pil.filter(ImageFilter.SMOOTH)
241+
im1pil.save(str(randomname3) + ".png")
242+
im1tk = PhotoImage(file=str(randomname3) + ".png")
243+
imageLabel.config(image=im1tk)
244+
os.remove(str(randomname3) + ".png")
245+
if counter == 1:
246+
global im2pil
247+
global im2tk
248+
im2pil.save(str(randomname3) + ".png")
249+
im2pil = Image.open(str(randomname3) + ".png")
250+
im2pil = im2pil.convert('RGB')
251+
im2pil = im2pil.filter(ImageFilter.SMOOTH)
252+
im2pil.save(str(randomname3) + ".png")
253+
im2tk = PhotoImage(file=str(randomname3) + ".png")
254+
imageLabel.config(image=im2tk)
255+
os.remove(str(randomname3) + ".png")
256+
if counter == 2:
257+
global im3pil
258+
global im3tk
259+
im3pil.save(str(randomname3) + ".png")
260+
im3pil = Image.open(str(randomname3) + ".png")
261+
im3pil = im3pil.convert('RGB')
262+
im3pil = im3pil.filter(ImageFilter.SMOOTH)
263+
im3pil.save(str(randomname3) + ".png")
264+
im3tk = PhotoImage(file=str(randomname3) + ".png")
265+
imageLabel.config(image=im3tk)
266+
os.remove(str(randomname3) + ".png")
267+
if counter == 3:
268+
global im4pil
269+
global im4tk
270+
im4pil.save(str(randomname3) + ".png")
271+
im4pil = Image.open(str(randomname3) + ".png")
272+
im4pil = im4pil.convert('RGB')
273+
im4pil = im4pil.filter(ImageFilter.SMOOTH)
274+
im4pil.save(str(randomname3) + ".png")
275+
im4tk = PhotoImage(file=str(randomname3) + ".png")
276+
imageLabel.config(image=im4tk)
277+
os.remove(str(randomname3) + ".png")
278+
if counter == 4:
279+
global im5pil
280+
global im5tk
281+
im5pil.save(str(randomname3) + ".png")
282+
im5pil = Image.open(str(randomname3) + ".png")
283+
im5pil = im5pil.convert('RGB')
284+
im5pil = im5pil.filter(ImageFilter.SMOOTH)
285+
im5pil.save(str(randomname3) + ".png")
286+
im5tk = PhotoImage(file=str(randomname3) + ".png")
287+
imageLabel.config(image=im5tk)
288+
os.remove(str(randomname3) + ".png")
289+
290+
291+
def detail():
292+
randomname1 = random.randint(1, 10000)
293+
randomname2 = random.randint(1, 10000)
294+
randomname3 = randomname1 + randomname2
295+
if counter == 0:
296+
global im1pil
297+
global im1tk
298+
im1pil.save(str(randomname3) + ".png")
299+
im1pil = Image.open(str(randomname3) + ".png")
300+
im1pil = im1pil.convert('RGB')
301+
im1pil = im1pil.filter(ImageFilter.DETAIL)
302+
im1pil.save(str(randomname3) + ".png")
303+
im1tk = PhotoImage(file=str(randomname3) + ".png")
304+
imageLabel.config(image=im1tk)
305+
os.remove(str(randomname3) + ".png")
306+
if counter == 1:
307+
global im2pil
308+
global im2tk
309+
im2pil.save(str(randomname3) + ".png")
310+
im2pil = Image.open(str(randomname3) + ".png")
311+
im2pil = im2pil.convert('RGB')
312+
im2pil = im2pil.filter(ImageFilter.DETAIL)
313+
im2pil.save(str(randomname3) + ".png")
314+
im2tk = PhotoImage(file=str(randomname3) + ".png")
315+
imageLabel.config(image=im2tk)
316+
os.remove(str(randomname3) + ".png")
317+
if counter == 2:
318+
global im3pil
319+
global im3tk
320+
im3pil.save(str(randomname3) + ".png")
321+
im3pil = Image.open(str(randomname3) + ".png")
322+
im3pil = im3pil.convert('RGB')
323+
im3pil = im3pil.filter(ImageFilter.DETAIL)
324+
im3pil.save(str(randomname3) + ".png")
325+
im3tk = PhotoImage(file=str(randomname3) + ".png")
326+
imageLabel.config(image=im3tk)
327+
os.remove(str(randomname3) + ".png")
328+
if counter == 3:
329+
global im4pil
330+
global im4tk
331+
im4pil.save(str(randomname3) + ".png")
332+
im4pil = Image.open(str(randomname3) + ".png")
333+
im4pil = im4pil.convert('RGB')
334+
im4pil = im4pil.filter(ImageFilter.DETAIL)
335+
im4pil.save(str(randomname3) + ".png")
336+
im4tk = PhotoImage(file=str(randomname3) + ".png")
337+
imageLabel.config(image=im4tk)
338+
os.remove(str(randomname3) + ".png")
339+
if counter == 4:
340+
global im5pil
341+
global im5tk
342+
im5pil.save(str(randomname3) + ".png")
343+
im5pil = Image.open(str(randomname3) + ".png")
344+
im5pil = im5pil.convert('RGB')
345+
im5pil = im5pil.filter(ImageFilter.DETAIL)
346+
im5pil.save(str(randomname3) + ".png")
347+
im5tk = PhotoImage(file=str(randomname3) + ".png")
348+
imageLabel.config(image=im5tk)
349+
os.remove(str(randomname3) + ".png")
350+
351+
352+
def contour():
353+
randomname1 = random.randint(1, 10000)
354+
randomname2 = random.randint(1, 10000)
355+
randomname3 = randomname1 + randomname2
356+
if counter == 0:
357+
global im1pil
358+
global im1tk
359+
im1pil.save(str(randomname3) + ".png")
360+
im1pil = Image.open(str(randomname3) + ".png")
361+
im1pil = im1pil.convert('RGB')
362+
im1pil = im1pil.filter(ImageFilter.CONTOUR)
363+
im1pil.save(str(randomname3) + ".png")
364+
im1tk = PhotoImage(file=str(randomname3) + ".png")
365+
imageLabel.config(image=im1tk)
366+
os.remove(str(randomname3) + ".png")
367+
if counter == 1:
368+
global im2pil
369+
global im2tk
370+
im2pil.save(str(randomname3) + ".png")
371+
im2pil = Image.open(str(randomname3) + ".png")
372+
im2pil = im2pil.convert('RGB')
373+
im2pil = im2pil.filter(ImageFilter.CONTOUR)
374+
im2pil.save(str(randomname3) + ".png")
375+
im2tk = PhotoImage(file=str(randomname3) + ".png")
376+
imageLabel.config(image=im2tk)
377+
os.remove(str(randomname3) + ".png")
378+
if counter == 2:
379+
global im3pil
380+
global im3tk
381+
im3pil.save(str(randomname3) + ".png")
382+
im3pil = Image.open(str(randomname3) + ".png")
383+
im3pil = im3pil.convert('RGB')
384+
im3pil = im3pil.filter(ImageFilter.CONTOUR)
385+
im3pil.save(str(randomname3) + ".png")
386+
im3tk = PhotoImage(file=str(randomname3) + ".png")
387+
imageLabel.config(image=im3tk)
388+
os.remove(str(randomname3) + ".png")
389+
if counter == 3:
390+
global im4pil
391+
global im4tk
392+
im4pil.save(str(randomname3) + ".png")
393+
im4pil = Image.open(str(randomname3) + ".png")
394+
im4pil = im4pil.convert('RGB')
395+
im4pil = im4pil.filter(ImageFilter.CONTOUR)
396+
im4pil.save(str(randomname3) + ".png")
397+
im4tk = PhotoImage(file=str(randomname3) + ".png")
398+
imageLabel.config(image=im4tk)
399+
os.remove(str(randomname3) + ".png")
400+
if counter == 4:
401+
global im5pil
402+
global im5tk
403+
im5pil.save(str(randomname3) + ".png")
404+
im5pil = Image.open(str(randomname3) + ".png")
405+
im5pil = im5pil.convert('RGB')
406+
im5pil = im5pil.filter(ImageFilter.CONTOUR)
407+
im5pil.save(str(randomname3) + ".png")
408+
im5tk = PhotoImage(file=str(randomname3) + ".png")
409+
imageLabel.config(image=im5tk)
410+
os.remove(str(randomname3) + ".png")
411+
412+
413+
def emboss():
414+
randomname1 = random.randint(1, 10000)
415+
randomname2 = random.randint(1, 10000)
416+
randomname3 = randomname1 + randomname2
417+
if counter == 0:
418+
global im1pil
419+
global im1tk
420+
im1pil.save(str(randomname3) + ".png")
421+
im1pil = Image.open(str(randomname3) + ".png")
422+
im1pil = im1pil.convert('RGB')
423+
im1pil = im1pil.filter(ImageFilter.EMBOSS)
424+
im1pil.save(str(randomname3) + ".png")
425+
im1tk = PhotoImage(file=str(randomname3) + ".png")
426+
imageLabel.config(image=im1tk)
427+
os.remove(str(randomname3) + ".png")
428+
if counter == 1:
429+
global im2pil
430+
global im2tk
431+
im2pil.save(str(randomname3) + ".png")
432+
im2pil = Image.open(str(randomname3) + ".png")
433+
im2pil = im2pil.convert('RGB')
434+
im2pil = im2pil.filter(ImageFilter.EMBOSS)
435+
im2pil.save(str(randomname3) + ".png")
436+
im2tk = PhotoImage(file=str(randomname3) + ".png")
437+
imageLabel.config(image=im2tk)
438+
os.remove(str(randomname3) + ".png")
439+
if counter == 2:
440+
global im3pil
441+
global im3tk
442+
im3pil.save(str(randomname3) + ".png")
443+
im3pil = Image.open(str(randomname3) + ".png")
444+
im3pil = im3pil.convert('RGB')
445+
im3pil = im3pil.filter(ImageFilter.EMBOSS)
446+
im3pil.save(str(randomname3) + ".png")
447+
im3tk = PhotoImage(file=str(randomname3) + ".png")
448+
imageLabel.config(image=im3tk)
449+
os.remove(str(randomname3) + ".png")
450+
if counter == 3:
451+
global im4pil
452+
global im4tk
453+
im4pil.save(str(randomname3) + ".png")
454+
im4pil = Image.open(str(randomname3) + ".png")
455+
im4pil = im4pil.convert('RGB')
456+
im4pil = im4pil.filter(ImageFilter.EMBOSS)
457+
im4pil.save(str(randomname3) + ".png")
458+
im4tk = PhotoImage(file=str(randomname3) + ".png")
459+
imageLabel.config(image=im4tk)
460+
os.remove(str(randomname3) + ".png")
461+
if counter == 4:
462+
global im5pil
463+
global im5tk
464+
im5pil.save(str(randomname3) + ".png")
465+
im5pil = Image.open(str(randomname3) + ".png")
466+
im5pil = im5pil.convert('RGB')
467+
im5pil = im5pil.filter(ImageFilter.EMBOSS)
468+
im5pil.save(str(randomname3) + ".png")
469+
im5tk = PhotoImage(file=str(randomname3) + ".png")
470+
imageLabel.config(image=im5tk)
471+
os.remove(str(randomname3) + ".png")
472+
473+
474+
def open():
475+
randomname1 = random.randint(1, 10000)
476+
randomname2 = random.randint(1, 10000)
477+
randomname3 = randomname1 + randomname2
478+
newsize = (512, 512)
479+
filename = filedialog.askopenfilename(initialdir="/",title="Select a File",filetypes=(("Image files","*.png;*.jpeg;*.jpg;*.bmp;*.xpm;*.dds;*.psd;*.webp;*.tiff;*.tga;*.dds;*.dib;*.icns;*.ico;*.im;*.msp;*.wmf;*.emf;*.pcx;*.pbm;*.ppm;*.pgm;*.pnm;*.sgi;*.blp;*.eps;*.sun;*.wal"),("All files","*.*")))
480+
if counter == 0:
481+
global im1pil
482+
global im1tk
483+
im1pil = Image.open(str(filename))
484+
im1pil = im1pil.resize(newsize, 0)
485+
im1pil = im1pil.convert('RGB')
486+
im1pil.save(str(randomname3) + ".png")
487+
im1tk = PhotoImage(file=str(randomname3) + ".png")
488+
imageLabel.config(image=im1tk)
489+
os.remove(str(randomname3) + ".png")
490+
if counter == 1:
491+
global im2pil
492+
global im2tk
493+
im2pil = Image.open(str(filename))
494+
im2pil = im2pil.resize(newsize, 0)
495+
im2pil = im2pil.convert('RGB')
496+
im2pil.save(str(randomname3) + ".png")
497+
im2tk = PhotoImage(file=str(randomname3) + ".png")
498+
imageLabel.config(image=im2tk)
499+
os.remove(str(randomname3) + ".png")
500+
if counter == 2:
501+
global im3pil
502+
global im3tk
503+
im3pil = Image.open(str(filename))
504+
im3pil = im3pil.resize(newsize, 0)
505+
im3pil = im3pil.convert('RGB')
506+
im3pil.save(str(randomname3) + ".png")
507+
im3tk = PhotoImage(file=str(randomname3) + ".png")
508+
imageLabel.config(image=im3tk)
509+
os.remove(str(randomname3) + ".png")
510+
if counter == 3:
511+
global im4pil
512+
global im4tk
513+
im4pil = Image.open(str(filename))
514+
im4pil = im4pil.resize(newsize, 0)
515+
im4pil = im4pil.convert('RGB')
516+
im4pil.save(str(randomname3) + ".png")
517+
im4tk = PhotoImage(file=str(randomname3) + ".png")
518+
imageLabel.config(image=im4tk)
519+
os.remove(str(randomname3) + ".png")
520+
if counter == 4:
521+
global im5pil
522+
global im5tk
523+
im5pil = Image.open(str(filename))
524+
im5pil = im5pil.resize(newsize, 0)
525+
im5pil = im5pil.convert('RGB')
526+
im5pil.save(str(randomname3) + ".png")
527+
im5tk = PhotoImage(file=str(randomname3) + ".png")
528+
imageLabel.config(image=im5tk)
529+
os.remove(str(randomname3) + ".png")
530+
531+
532+
def musicon():
533+
pygame.mixer.music.unpause()
534+
def musicoff():
535+
pygame.mixer.music.pause()
536+
537+
228538
def helpinfo():
539+
def callback(url):
540+
webbrowser.open_new_tab(url)
541+
229542
helpwindow = Toplevel(root)
230-
helpwindow.title("Help")
231-
helpwindow.geometry("250x250")
543+
helpwindow.title("Info")
544+
helpwindow.geometry("350x150")
545+
helpwindow.minsize(350, 150)
546+
helpwindow.maxsize(350, 150)
547+
helpwindow.resizable(False, False)
548+
helptext = Label(helpwindow,
549+
text="Credits:\nPython: Python Software Foundation.\nTkinter: Steen Lumholt and Guido van Rossum.\nPillow: Fredrik Lundh, Jeffrey A. Clark.\nPygame: Pete Shinners.\nRandom: Python Software Foundation.\nOS: Python Software Foundation.\nWebBrowser: Python Software Foundation.",
550+
font=('Minecraft Pixel Font 5x5 Regular', 6))
551+
helptext.pack()
552+
githublink = Label(helpwindow, text='Source Code', font=('Minecraft Pixel Font 5x5 Regular', 22), fg="blue",
553+
cursor="hand2")
554+
githublink.pack()
555+
githublink.bind("<Button-1>", lambda e:
556+
callback("https://github.com/LandonPerkinsProsser/SimpleImageSlideshow"))
232557
helpwindow.mainloop()
233558

234559

@@ -241,15 +566,24 @@ def helpinfo():
241566
font=('Minecraft Pixel Font 5x5 Regular', 20))
242567
menubar1 = Menu(root)
243568
filemenu1 = Menu(menubar1, tearoff=0)
569+
filemenu1.add_command(label="Open", command=open)
244570
filemenu1.add_command(label="Save", command=save)
245571
menubar1.add_cascade(label="File", menu=filemenu1)
246572
filemenu2 = Menu(menubar1, tearoff=0)
247573
filemenu2.add_command(label="Blur", command=blur)
248574
filemenu2.add_command(label="Sharpen", command=sharpen)
575+
filemenu2.add_command(label="Smooth", command=smoothen)
576+
filemenu2.add_command(label="Detail", command=detail)
577+
filemenu2.add_command(label="Contour", command=contour)
578+
filemenu2.add_command(label="Emboss", command=emboss)
249579
menubar1.add_cascade(label="Edit", menu=filemenu2)
250580
filemenu3 = Menu(menubar1, tearoff=0)
251-
filemenu3.add_command(label="Info", command=helpinfo)
252-
menubar1.add_cascade(label="Help", menu=filemenu3)
581+
filemenu3.add_command(label="Music On", command=musicon)
582+
filemenu3.add_command(label="Music Off", command=musicoff)
583+
menubar1.add_cascade(label="Music", menu=filemenu3)
584+
filemenu4 = Menu(menubar1, tearoff=0)
585+
filemenu4.add_command(label="Info", command=helpinfo)
586+
menubar1.add_cascade(label="Help", menu=filemenu4)
253587
root.config(menu=menubar1)
254588
button = Button(root, text="Next Image", font=('Minecraft Pixel Font 5x5 Regular', 20), command=nextimage)
255589
infoLabel.pack()

0 commit comments

Comments
 (0)