Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
ImageConverter 1.0 - Imageconverter.py

Imageconverter.py

Caricato da: MillenniumBug
Scarica il programma completo

  1. #ImageConverter 1.0
  2. #Creato da MillenniumBug
  3. from Tkinter import *
  4. import tkFileDialog, Image, os,tkMessageBox
  5. def Sfoglia():
  6.     global fil, est,img
  7.     ftipi=(('Gif Images', '*.gif'),
  8.             ('Jpeg Images', '*.jpg'),
  9.             ('Png Images', '*.png'),
  10.             ('Tiff Images', '*.tif'),
  11.             ('Bitmap Images', '*.bmp'),
  12.             ('PDF Images', '*.pdf'),
  13.             ("All files", "*"))
  14.     dialog=tkFileDialog.Open(filetypes=ftipi)
  15.     path=dialog.show()
  16.     fil, est = os.path.splitext(path)
  17.     img=Image.open(path)
  18.     return fil, est, img
  19. def Converti():
  20.     est = var.get()
  21.     img.save(fil+"2"+est)
  22. def about():
  23.     tkMessageBox.showinfo(title='About', message='Image Converter 1.0\nCreato da MillenniumBug\nSito web: www.pyprogram.altervista.org')
  24. def guida():
  25.     tkMessageBox.showinfo(title='Guida', message='Premere Sfoglia\nSelezionare file\nselezionare formato\npremere Converti')
  26. def rit():
  27.         w=width.get()
  28.         h=height.get()
  29.         img2= img.resize((w, h), Image.NEAREST)
  30.         img2.save(fil+"resize"+est)
  31. root=Tk()
  32. root.title("Image Converter")
  33. root.geometry('284x200+100+100')
  34. var=StringVar(root)
  35. var.set('.png')
  36. op=OptionMenu(root, var, ".png", ".jpg", ".gif",".bmp",".pdf",".tif")
  37. button=Button(root,text="Sfoglia",command=Sfoglia)
  38. button2=Button(root,text="Converti",command=Converti)
  39. lab=Label(text="Image Converter")
  40. menubar = Menu(root)
  41. filemenu = Menu(menubar, tearoff=0)
  42. filemenu.add_command(label="Guida", command=guida)
  43. filemenu.add_separator()
  44. filemenu.add_command(label="Exit", command=root.quit)
  45. menubar.add_cascade(label="File", menu=filemenu)
  46. helpmenu = Menu(menubar, tearoff=0)
  47. helpmenu.add_command(label="About", command=about)
  48. menubar.add_cascade(label="Help", menu=helpmenu)
  49. lab.place(relx=0.00, rely=0.0, relwidth=0.4, relheight=0.2)
  50. button.place(relx=0.69, rely=0.0, relwidth=0.26, relheight=0.2)
  51. button2.place(relx=0.69, rely=0.2, relwidth=0.26, relheight=0.2)
  52. op.place(relx=0.3, rely=0.2, relwidth=0.26, relheight=0.2)
  53. root.config(menu=menubar)
  54. #Sezione ritaglia
  55. labsep=Label(text="Ritaglia Immagine")
  56. lab2=Label(text="Larghezza")
  57. lab2.place(relx=0.00, rely=0.6, relwidth=0.4, relheight=0.1)
  58. lab3=Label(text="Altezza")
  59. lab3.place(relx=0.00, rely=0.7, relwidth=0.4, relheight=0.1)
  60. labsep.place(relx=0.3, rely=0.5, relwidth=0.4, relheight=0.1)
  61. width=IntVar()
  62. height=IntVar()
  63. a=Entry(textvariable=width)
  64. b=Entry(textvariable=height)
  65. a.place(relx=0.50, rely=0.6, relwidth=0.5, relheight=0.1)
  66. b.place(relx=0.50, rely=0.7, relwidth=0.5, relheight=0.1)
  67. button3=Button(text="Ritaglia",command=rit)
  68. button3.place(relx=0.30, rely=0.8, relwidth=0.5, relheight=0.2)
  69. root.mainloop()