added basic rotate option to images

This commit is contained in:
tassaron 2017-07-05 23:04:09 -04:00
parent 3f7ead0d1f
commit 3de45b3629
3 changed files with 63 additions and 3 deletions

View File

@ -15,13 +15,11 @@ class Component(Component):
self.parent = parent
self.settings = parent.settings
page = self.loadUi('image.ui')
self.imagePath = ''
self.x = 0
self.y = 0
page.lineEdit_image.textChanged.connect(self.update)
page.pushButton_image.clicked.connect(self.pickImage)
page.spinBox_scale.valueChanged.connect(self.update)
page.spinBox_rotate.valueChanged.connect(self.update)
page.checkBox_stretch.stateChanged.connect(self.update)
page.spinBox_x.valueChanged.connect(self.update)
page.spinBox_y.valueChanged.connect(self.update)
@ -32,6 +30,7 @@ class Component(Component):
def update(self):
self.imagePath = self.page.lineEdit_image.text()
self.scale = self.page.spinBox_scale.value()
self.rotate = self.page.spinBox_rotate.value()
self.xPosition = self.page.spinBox_x.value()
self.yPosition = self.page.spinBox_y.value()
self.stretched = self.page.checkBox_stretch.isChecked()
@ -64,12 +63,15 @@ class Component(Component):
newWidth = int((image.width / 100) * self.scale)
image = image.resize((newWidth, newHeight), Image.ANTIALIAS)
frame.paste(image, box=(self.xPosition, self.yPosition))
if self.rotate != 0:
frame = frame.rotate(self.rotate)
return frame
def loadPreset(self, pr, presetName=None):
super().loadPreset(pr, presetName)
self.page.lineEdit_image.setText(pr['image'])
self.page.spinBox_scale.setValue(pr['scale'])
self.page.spinBox_rotate.setValue(pr['rotate'])
self.page.spinBox_x.setValue(pr['x'])
self.page.spinBox_y.setValue(pr['y'])
self.page.checkBox_stretch.setChecked(pr['stretched'])
@ -79,6 +81,7 @@ class Component(Component):
'preset': self.currentPreset,
'image': self.imagePath,
'scale': self.scale,
'rotate': self.rotate,
'stretched': self.stretched,
'x': self.xPosition,
'y': self.yPosition,

View File

@ -208,8 +208,59 @@
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Rotation</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBox_rotate">
<property name="buttonSymbols">
<enum>QAbstractSpinBox::UpDownArrows</enum>
</property>
<property name="suffix">
<string notr="true">°</string>
</property>
<property name="minimum">
<number>0</number>
</property>
<property name="maximum">
<number>359</number>
</property>
<property name="value">
<number>0</number>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>10</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Scale</string>
</property>

View File

@ -55,6 +55,9 @@ def openPipe(commandList, **kwargs):
def disableWhenEncoding(func):
''' Blocks calls to a function while the video is being exported
in MainWindow.
'''
def decorator(*args, **kwargs):
if args[0].encoding:
return
@ -64,6 +67,9 @@ def disableWhenEncoding(func):
def LoadDefaultSettings(self):
''' Runs once at each program start-up. Fills in default settings
for any settings not found in settings.ini
'''
self.resolutions = [
'1920x1080',
'1280x720',