Skip to content
Snippets Groups Projects
Commit fa50ccf0 authored by Valentin Rigal's avatar Valentin Rigal Committed by Erwan Rouchet
Browse files

Always convert images to RGB mode on Transkribus imports

parent 06a3bfd4
No related branches found
No related tags found
1 merge request!366Always convert images to RGB mode on Transkribus imports
Pipeline #141841 passed
......@@ -23,10 +23,6 @@ from arkindex_tasks.utils import default_client, retried_request
logging.basicConfig(format="[%(levelname)s] %(message)s", level=logging.INFO)
logger = logging.getLogger(__name__)
# Image formats that should not be converted before uploading
# see https://pillow.readthedocs.io/en/5.1.x/handbook/image-file-formats.html
VALID_IMAGE_FORMATS = ["JPEG", "JPEG2000", "PNG"]
def hash_file(path) -> str:
md5 = hashlib.md5()
......@@ -70,10 +66,9 @@ class TranskribusElement(object):
shutil.copyfileobj(source, destination)
with Image.open(img_path) as img:
if img.format not in VALID_IMAGE_FORMATS:
# Convert to RGB if needed
if img.mode != "RGB":
img = img.convert("RGB")
# Convert to RGB if needed
if img.mode != "RGB":
img = img.convert("RGB")
# Apply the rotation/transposition from the EXIF orientation tag if it is used
img = ImageOps.exif_transpose(img)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment