The problem of efficiency improvement
Before friends need to use a large number of images to distinguish between the resolution, he said that all open pictures, and then use a ruler on the screen volume ... I am also a waterfall Khan .... Spend a little bit of time helping him write small software to solve this problem of egg ache
Solution Solutions
I want to use batch processing, but considering the ease of use, the Python Tkinter made a simple interface convenient operation.
He is not a program developer, let him install the Python environment is not realistic, need to use packaging tools to deal with, online see a lot of py2exe, look a bit troublesome, I directly with Pyinstaller packaging, a line of code to do.
Source
1 #-*-coding:utf-8-*-2 ImportOS3 fromPILImportImage as Pilimage4 fromTkinterImport*5 ImportTkinter.messagebox as MessageBox6 ImportTkinter.filedialog As Dialog7 8 classApplication (Frame):9 def __init__(Self, master=None):TenFrame.__init__(self, master) One Self.pack () A self.createwidgets () - - defcreatewidgets (self): theLabel (Self, text="Enter Address:", Font= ("Microsoft Ya-Black", width=10, height=1). Grid (row=0) -Label (Self, text="Output Address:", Font= ("Microsoft Ya-Black", width=10, height=1). Grid (Row=1) -Label (Self, text="Aspect ratio:", Font= ("Microsoft Ya-Black", width=10, height=1). Grid (row=2) -Self.ininput =Entry (self) +Self.outinput =Entry (self) -Self.mininput = Entry (self,width=8) +Label (Self, text="-", Font= ("Microsoft Ya-Black", Width=1, height=1). Grid (row=2,column=2) ASelf.maxinput = Entry (self,width=8) atSelf.inInput.grid (row=0,column=1,columnspan=3) -Self.outInput.grid (row=1,column=1,columnspan=3) -Self.minInput.grid (row=2,column=1) -Self.maxInput.grid (row=2,column=3) - -Self.minInput.insert (end,1) inSelf.maxInput.insert (end,1.1) - toSelf.inbutton = Button (self, text='Select', command=Self.openindir) +Self.outbutton = Button (self, text='Select', command=Self.openoutdir) -Self.inButton.grid (row=0,column=5) theSelf.outButton.grid (row=1,column=5) * $Self.excutebutton = Button (self, text='Output', command=self.export)Panax NotoginsengSelf.excuteButton.grid (row=2,column=5) - the defExport (self): +In_path =Self.inInput.get () AOut_path =Self.outInput.get () theExcute_path ="' +Excute_count =0 -Files =Os.listdir (In_path) $ forFileinchFiles: $Excute_path = In_path +'/'+file -im = Pilimage.open (Excute_path,'R') - ifIm.size[1]/im.size[0] >= float (self.minInput.get ()) andIm.size[1]/im.size[0] <=Float (Self.maxInput.get ()): theIm.save (Out_path +'/'+ File,"PNG") - Print(Out_path +'/'+file)WuyiExcute_count = Excute_count + 1 theMessagebox.showinfo ('Message', Excute_count) - Wu defOpenindir (self): - Self.inInput.delete (0,end) About Self.inInput.insert (End,dialog.askdirectory ()) $ - defOpenoutdir (self): - Self.outInput.delete (0,end) - Self.outInput.insert (End,dialog.askdirectory ()) A +App =application () theApp.master.title ('image Processing') -App.mainloop ()
Other related
Here are the directly packaged EXE problem----->
Run:
Export pictures as needed for the aspect ratio separately (Python 3)