Skip to content

Commit

Permalink
Add possibility to rotate photo for horizontal frame #63
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeGawi committed Apr 24, 2022
1 parent 5af5a90 commit 15e2de9
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 6 deletions.
4 changes: 4 additions & 0 deletions config.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,10 @@ auto_orientation=0
# Default:1 (horizontal)
horizontal=1

# Indicates if photo should be turned upside-down for horizontal frame position.
# Default:0 (normal)
turned=0

# Frame rotation in vertical position.
# Values: 90 (right) or 270 (left) degrees.
# Default: 90
Expand Down
4 changes: 4 additions & 0 deletions misc/config.default
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,10 @@ auto_orientation=0
# Default:1 (horizontal)
horizontal=1

# Indicates if photo should be turned upside-down for horizontal frame position.
# Default:0 (normal)
turned=0

# Frame rotation in vertical position.
# Values: 90 (right) or 270 (left) degrees.
# Default: 90
Expand Down
2 changes: 1 addition & 1 deletion misc/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

class constants:

EPIFRAME_VERSION = 'v1.6.0'
EPIFRAME_VERSION = 'v1.7.0'
EPIFRAME_SECRET = 'ePiframeSecretlyLovesYourPhotos'

#minimal needed python version
Expand Down
3 changes: 2 additions & 1 deletion modules/configmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ def load_settings(self):
configprop('grayscale', self, prop_type=configprop.BOOLEAN_TYPE, dependency=['display_type', displaymanager.get_hdmi()]),
configprop('colors_num', self, minvalue=1, notempty=False, prop_type=configprop.INTEGER_TYPE, dependency=['display_type', displaymanager.get_hdmi()]),
configprop('horizontal', self, prop_type=configprop.BOOLEAN_TYPE),
configprop('auto_orientation', self, prop_type=configprop.BOOLEAN_TYPE),
configprop('auto_orientation', self, prop_type=configprop.BOOLEAN_TYPE),
configprop('turned', self, prop_type=configprop.BOOLEAN_TYPE, dependency='horizontal'),
configprop('rotation', self, prop_type=configprop.INTEGER_TYPE, dependency=['horizontal', '0'], possible=convertmanager.get_rotation()),
configprop('auto_gamma', self, prop_type=configprop.BOOLEAN_TYPE),
configprop('auto_level', self, prop_type=configprop.BOOLEAN_TYPE),
Expand Down
10 changes: 6 additions & 4 deletions modules/convertmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ class convertmanager:

__ERROR_VALUE_TEXT = 'Configuration background_color should be one of {}'

__INVERT_FLAG = "-negate"
__ROTATE_CODE = '-rotate {}'
__INVERT_FLAG = "-negate "
__ROTATE_CODE = '-rotate {} '
__BACK_COLORS = ["white", "black", "photo"]
__GRAYSCALE_FLAG = "-colorspace Gray "
__COLORS_FLAG = "-colors {} "
Expand Down Expand Up @@ -74,8 +74,10 @@ def __convert_option (self, origwidth:int, origheight:int, target:str, config, h
if int(option) > len(self.__CONVERT_OPTIONS) or int(option) < 1: option = 1

#space at the end as those flag are optional
negate = self.__INVERT_FLAG + " " if config.getint('invert_colors') == 1 else ''
rotate = self.__ROTATE_CODE.format(config.getint('rotation')) + " " if config.getint('horizontal') == 0 else ''
negate = self.__INVERT_FLAG if config.getint('invert_colors') == 1 else ''
rotate = self.__ROTATE_CODE.format(config.getint('rotation')) if config.getint('horizontal') == 0 else ''

if config.getint('horizontal') == 1 and config.getint('turned') == 1: rotate = self.__ROTATE_CODE.format(180)

back = back.strip().lower()

Expand Down

0 comments on commit 15e2de9

Please sign in to comment.