added basic rotate option to images
This commit is contained in:
parent
3f7ead0d1f
commit
3de45b3629
|
@ -15,13 +15,11 @@ class Component(Component):
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
self.settings = parent.settings
|
self.settings = parent.settings
|
||||||
page = self.loadUi('image.ui')
|
page = self.loadUi('image.ui')
|
||||||
self.imagePath = ''
|
|
||||||
self.x = 0
|
|
||||||
self.y = 0
|
|
||||||
|
|
||||||
page.lineEdit_image.textChanged.connect(self.update)
|
page.lineEdit_image.textChanged.connect(self.update)
|
||||||
page.pushButton_image.clicked.connect(self.pickImage)
|
page.pushButton_image.clicked.connect(self.pickImage)
|
||||||
page.spinBox_scale.valueChanged.connect(self.update)
|
page.spinBox_scale.valueChanged.connect(self.update)
|
||||||
|
page.spinBox_rotate.valueChanged.connect(self.update)
|
||||||
page.checkBox_stretch.stateChanged.connect(self.update)
|
page.checkBox_stretch.stateChanged.connect(self.update)
|
||||||
page.spinBox_x.valueChanged.connect(self.update)
|
page.spinBox_x.valueChanged.connect(self.update)
|
||||||
page.spinBox_y.valueChanged.connect(self.update)
|
page.spinBox_y.valueChanged.connect(self.update)
|
||||||
|
@ -32,6 +30,7 @@ class Component(Component):
|
||||||
def update(self):
|
def update(self):
|
||||||
self.imagePath = self.page.lineEdit_image.text()
|
self.imagePath = self.page.lineEdit_image.text()
|
||||||
self.scale = self.page.spinBox_scale.value()
|
self.scale = self.page.spinBox_scale.value()
|
||||||
|
self.rotate = self.page.spinBox_rotate.value()
|
||||||
self.xPosition = self.page.spinBox_x.value()
|
self.xPosition = self.page.spinBox_x.value()
|
||||||
self.yPosition = self.page.spinBox_y.value()
|
self.yPosition = self.page.spinBox_y.value()
|
||||||
self.stretched = self.page.checkBox_stretch.isChecked()
|
self.stretched = self.page.checkBox_stretch.isChecked()
|
||||||
|
@ -64,12 +63,15 @@ class Component(Component):
|
||||||
newWidth = int((image.width / 100) * self.scale)
|
newWidth = int((image.width / 100) * self.scale)
|
||||||
image = image.resize((newWidth, newHeight), Image.ANTIALIAS)
|
image = image.resize((newWidth, newHeight), Image.ANTIALIAS)
|
||||||
frame.paste(image, box=(self.xPosition, self.yPosition))
|
frame.paste(image, box=(self.xPosition, self.yPosition))
|
||||||
|
if self.rotate != 0:
|
||||||
|
frame = frame.rotate(self.rotate)
|
||||||
return frame
|
return frame
|
||||||
|
|
||||||
def loadPreset(self, pr, presetName=None):
|
def loadPreset(self, pr, presetName=None):
|
||||||
super().loadPreset(pr, presetName)
|
super().loadPreset(pr, presetName)
|
||||||
self.page.lineEdit_image.setText(pr['image'])
|
self.page.lineEdit_image.setText(pr['image'])
|
||||||
self.page.spinBox_scale.setValue(pr['scale'])
|
self.page.spinBox_scale.setValue(pr['scale'])
|
||||||
|
self.page.spinBox_rotate.setValue(pr['rotate'])
|
||||||
self.page.spinBox_x.setValue(pr['x'])
|
self.page.spinBox_x.setValue(pr['x'])
|
||||||
self.page.spinBox_y.setValue(pr['y'])
|
self.page.spinBox_y.setValue(pr['y'])
|
||||||
self.page.checkBox_stretch.setChecked(pr['stretched'])
|
self.page.checkBox_stretch.setChecked(pr['stretched'])
|
||||||
|
@ -79,6 +81,7 @@ class Component(Component):
|
||||||
'preset': self.currentPreset,
|
'preset': self.currentPreset,
|
||||||
'image': self.imagePath,
|
'image': self.imagePath,
|
||||||
'scale': self.scale,
|
'scale': self.scale,
|
||||||
|
'rotate': self.rotate,
|
||||||
'stretched': self.stretched,
|
'stretched': self.stretched,
|
||||||
'x': self.xPosition,
|
'x': self.xPosition,
|
||||||
'y': self.yPosition,
|
'y': self.yPosition,
|
||||||
|
|
|
@ -208,8 +208,59 @@
|
||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</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>
|
<item>
|
||||||
<widget class="QLabel" name="label">
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Scale</string>
|
<string>Scale</string>
|
||||||
</property>
|
</property>
|
||||||
|
|
|
@ -55,6 +55,9 @@ def openPipe(commandList, **kwargs):
|
||||||
|
|
||||||
|
|
||||||
def disableWhenEncoding(func):
|
def disableWhenEncoding(func):
|
||||||
|
''' Blocks calls to a function while the video is being exported
|
||||||
|
in MainWindow.
|
||||||
|
'''
|
||||||
def decorator(*args, **kwargs):
|
def decorator(*args, **kwargs):
|
||||||
if args[0].encoding:
|
if args[0].encoding:
|
||||||
return
|
return
|
||||||
|
@ -64,6 +67,9 @@ def disableWhenEncoding(func):
|
||||||
|
|
||||||
|
|
||||||
def LoadDefaultSettings(self):
|
def LoadDefaultSettings(self):
|
||||||
|
''' Runs once at each program start-up. Fills in default settings
|
||||||
|
for any settings not found in settings.ini
|
||||||
|
'''
|
||||||
self.resolutions = [
|
self.resolutions = [
|
||||||
'1920x1080',
|
'1920x1080',
|
||||||
'1280x720',
|
'1280x720',
|
||||||
|
|
Reference in New Issue