]> git.plutz.net Git - viper/blob - plugins/f_crop.py
implemeted most basic cropping controls
[viper] / plugins / f_crop.py
1 #encoding: utf-8
2 #Copyright 2011 Thomas Kretzer, Paul Hänsch
3
4 #This file is part of Viper. 
5
6 #Viper is free software: you can redistribute it and/or modify
7 #it under the terms of the GNU General Public License as published by
8 #the Free Software Foundation, either version 3 of the License, or
9 #(at your option) any later version.
10
11 #Viper is distributed in the hope that it will be useful,
12 #but WITHOUT ANY WARRANTY; without even the implied warranty of
13 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 #GNU General Public License for more details.
15
16 #You should have received a copy of the GNU General Public License
17 #along with Viper.  If not, see <http://www.gnu.org/licenses/>
18
19 from plugin import *
20
21 # TODO
22 # Controls to adjust cropping position
23
24 class F_Crop(F_Plugin):
25     def build_dialog(self):
26         self.subgets['desc'] = Label(self, text = 'Crop image, only centered cropping so far\n'+
27                                                   'Cropping the image will change its resolution.\n'+
28                                                   'When cropping only a few chunks out of a larger set\n'+
29                                                   'you might also want to add a scale filter.')
30         self.subgets['desc'].pack(side = TOP, expand = True, fill = BOTH)
31
32         self.subgets['f_spin'] = Frame(self)
33         self.subgets['f_spin'].pack(side = TOP, anchor = N, expand = True, fill = BOTH)
34         self.subgets['l_width'] = Label(self.subgets['f_spin'], text = 'Width:')
35         self.subgets['l_width'].pack(side = LEFT, anchor = N)
36         self.subgets['s_width'] = Spinbox(self.subgets['f_spin'], from_ = 0, to = 8192, wrap = False, width = 5)
37         self.subgets['s_width'].delete(0, END)
38         self.subgets['s_width'].insert(0, 320)
39         self.subgets['s_width'].pack(side = LEFT, anchor = N, fill = X)
40         self.subgets['s_height'] = Spinbox(self.subgets['f_spin'], from_ = -2, to = 8192, wrap = False, width = 5)
41         self.subgets['s_height'].delete(0, END)
42         self.subgets['s_height'].insert(0, 240)
43         self.subgets['s_height'].pack(side = RIGHT, anchor = N, fill = X)
44         self.subgets['l_height'] = Label(self.subgets['f_spin'], text = 'Height:')
45         self.subgets['l_height'].pack(side = RIGHT, anchor = N)
46
47     def name(self):
48         return 'Crop'
49
50     def subcommand(self):
51         return ['-vf-add', 'crop=' + str(self.subgets['s_width'].get()) + ':' + str(self.subgets['s_height'].get())]
52     def subcommand(self):
53         return self.subgets['filter'].getvalue().split(' ')
54