Skip to content

Commit 9771be8

Browse files
committed
No processing option #112 - no convert config added
1 parent 1c688a7 commit 9771be8

File tree

6 files changed

+44
-11
lines changed

6 files changed

+44
-11
lines changed

INSTALL.md

+5
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* [Local Source](#local-source)
1010
* [Cloud sync](#cloud-sync)
1111
* [Other sources](#other-sources)
12+
* [Pre-process photos](#pre-process-photos)
1213
* [Google Photos](#google-photos)
1314
* [Activate from ePiframe device](#activate-from-epiframe-device)
1415
* [Activate from other device](#activate-from-other-device)
@@ -150,6 +151,10 @@ It is possible to download photos to a local storage (and use them by ePiframe)
150151
* [gallery-dl](https://github.com/mikf/gallery-dl) - a command-line program to download image galleries and collections from DeviantArt, Flickr, Instagram, Pinterest and many more
151152
* [iCloud Photos Downloader](https://github.com/icloud-photos-downloader/icloud_photos_downloader) - a command-line tool to download all your iCloud photos
152153

154+
### Pre-process photos
155+
156+
If you want photos to be pre-processed and ready for display in the frame (to save resources during conversion or to convert them earlier, on another device), this is possible using the `--convert` option command in [ePiframe commands](#command-line) and disabling conversion in [*config.cfg*](https://github.com/MikeGawi/ePiframe/blob/master/config.cfg) by switching the `convert` flag off.
157+
153158
## Google Photos
154159

155160
ePiframe needs to have credentials and *access token* to access Google Photos of Google account in an unsupervised way when Google Photos source is enabled in the configuration. For this You need to activate Google Photos API for the account used by ePiframe and configure application in Google Cloud Console.

config.cfg

+6
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,12 @@ allow_triggers=1
211211

212212
[Image]
213213

214+
# Convert before displaying.
215+
# If disabled, then You must have your photos pre-converted via the ePiframe command line!
216+
# Command line actions will always work.
217+
# Default: 1
218+
convert=1
219+
214220
# Used for e-Paper SPI _black&white_ displays!
215221
# There are 6 standard types of conversion to black&white image (add more in
216222
# convertmanager module). Every option gives slightly different

ePiframe.py

+18-8
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import signal
88
import sys
99
from datetime import datetime
10+
from typing import List
11+
1012
import pandas
1113
import starlette.status
1214
from pandas import DataFrame
@@ -627,7 +629,12 @@ def process_file(
627629
self.logging.log("Success!")
628630
self.interval_multiplication(filename, photo)
629631
self.save_index()
630-
self.convert_file(filename, photo)
632+
if bool(self.config.getint("convert")):
633+
self.convert_file(filename, photo)
634+
else:
635+
self.logging.log(
636+
"Conversion disabled in config by 'config' flag! Make sure your photos are pre-converted!"
637+
)
631638

632639
def save_index(self):
633640
# save index of current photo for next run
@@ -662,13 +669,9 @@ def save_pid(self):
662669
raise
663670

664671
def check_system(self):
665-
if (
666-
not self.check_arguments("--test")
667-
and not self.check_arguments("--test-convert")
668-
and not self.check_arguments("--convert")
669-
and not self.check_arguments("--no-skip")
670-
and not DisplayManager.is_hdmi(self.config.get("display_type"))
671-
):
672+
if not self.check_multiple_arguments(
673+
["--test", "--test-convert", "--convert", "--no-skip"]
674+
) and not DisplayManager.is_hdmi(self.config.get("display_type")):
672675
self.process_check_system()
673676

674677
def process_check_system(self):
@@ -734,6 +737,13 @@ def show_help(self):
734737

735738
sys.exit(0)
736739

740+
@staticmethod
741+
def check_multiple_arguments(names: List[str]) -> bool:
742+
return_value = False
743+
for name in names:
744+
return_value = return_value or EPiframe.check_arguments(name)
745+
return return_value
746+
737747
@staticmethod
738748
def check_arguments(name: str) -> bool:
739749
return name in [argument.lower() for argument in sys.argv]

misc/config.default

+6
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,12 @@ allow_triggers=1
211211

212212
[Image]
213213

214+
# Convert before displaying.
215+
# If disabled, then You must have your photos pre-converted via the ePiframe command line!
216+
# Command line actions will always work.
217+
# Default: 1
218+
convert=1
219+
214220
# Used for e-Paper SPI _black&white_ displays!
215221
# There are 6 standard types of conversion to black&white image (add more in
216222
# convertmanager module). Every option gives slightly different

modules/configmanager.py

+1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ def load_settings(self):
6363
ConfigProperty(
6464
"photo_convert_path", self, prop_type=ConfigProperty.FILE_TYPE
6565
),
66+
ConfigProperty("convert", self, prop_type=ConfigProperty.BOOLEAN_TYPE),
6667
ConfigProperty("log_files", self, not_empty=False),
6768
ConfigProperty(
6869
"convert_bin_path", self, prop_type=ConfigProperty.FILE_TYPE

modules/convertmanager.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,7 @@ def __convert_option(
125125
width = config.getint("image_width")
126126
height = config.getint("image_height")
127127
back = config.get("background_color")
128-
129-
if int(option) > len(self.__CONVERT_OPTIONS) or int(option) < 1:
130-
option = 1
128+
option = self.__get_option(option)
131129

132130
# space at the end as those flag are optional
133131
negate = self.__INVERT_FLAG if config.getint("invert_colors") == 1 else ""
@@ -167,6 +165,13 @@ def __convert_option(
167165
print(return_value.replace("(", "\(").replace(")", "\)"))
168166
return return_value
169167

168+
def __get_option(self, option: int) -> int:
169+
return (
170+
1
171+
if int(option) > len(self.__CONVERT_OPTIONS) or int(option) < 1
172+
else option
173+
)
174+
170175
def __get_background(self, back, height, original_height, original_width, width):
171176
if back == Constants.BACK_PHOTO:
172177
back = Constants.BACK_WHITE

0 commit comments

Comments
 (0)