From 776194e4c641a717c23417d93070a40eaaf904e8 Mon Sep 17 00:00:00 2001 From: kthoden Date: Fri, 25 Sep 2020 08:11:16 +0200 Subject: [PATCH] Rename jpeg extension to jpg --- src/imxml2epub.py | 10 +++++++++- src/utils/libeoaconvert.py | 6 ++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/imxml2epub.py b/src/imxml2epub.py index fab3e78..410a26d 100755 --- a/src/imxml2epub.py +++ b/src/imxml2epub.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 # -*- coding: utf-8; mode: python -*- -# Time-stamp: <2020-09-24 16:27:42 (kthoden)> +# Time-stamp: <2020-09-25 08:08:41 (kthoden)> """ Convert a customized DocBook XML file into a set of files that constitute the contents of an EPUB file. @@ -776,6 +776,10 @@ def add_css_snippet(css_snippet, css_file): strImageFileDir = re.sub("/", "", strImageFileDir) strImageFileName = os.path.basename(strImageFileString) strImageFileNamewoSuffix, strImageFileName_Suffix = os.path.splitext(strImageFileName) + + if strImageFileName_Suffix == ".jpeg": + strImageFileName = strImageFileName.replace(".jpeg", ".jpg") + shutil.copy( PUBLICATION_DIR / strImageFileString, OUTPUT_DIR / "OEBPS/images" / (strImageFileDir + strImageFileName) @@ -855,6 +859,10 @@ def add_css_snippet(css_snippet, css_file): strImageFileDir = re.sub("/", "", strImageFileDir) strImageFileName = os.path.basename(strImageFileString) strImageFileNamewoSuffix, strImageFileName_Suffix = os.path.splitext(strImageFileName) + + if strImageFileName_Suffix == ".jpeg": + strImageFileName = strImageFileName.replace(".jpeg", ".jpg") + shutil.copy( PUBLICATION_DIR / strImageFileString, OUTPUT_DIR / "OEBPS/images" / (strImageFileDir + strImageFileName) diff --git a/src/utils/libeoaconvert.py b/src/utils/libeoaconvert.py index cb334a2..7ac3f9e 100644 --- a/src/utils/libeoaconvert.py +++ b/src/utils/libeoaconvert.py @@ -106,14 +106,12 @@ def sanitizeImage( strFileFormat = strFileFormat_bytes.decode("utf-8").strip() logging.debug(f"Image has been recognized as having format {strFileFormat} by {GM_PATH}.") if strFileFormat == "JPEG": - pass - # print("looking at jpeg file") - # strNewImagepath = os.path.splitext(strImagepath)[0] + strNewImagepath = os.path.splitext(strImagepath)[0] # strCommand = GM_PATH + " convert " + strImagepath + " " + strNewImagepath + ".jpg" # listArguments = shlex.split(strCommand) # subprocess.call(listArguments) # os.remove(strImagepath) - # strImagepath = strNewImagepath + ".jpg" + strImagepath = strNewImagepath + ".jpg" elif strFileFormat == "PNG": pass # print("looking at png file")