From 3e8894c7da88254b9ec007198ca5f7a3ab075481 Mon Sep 17 00:00:00 2001 From: Johannes 'josch' Schauer Date: Wed, 17 Feb 2016 00:37:13 +0100 Subject: [PATCH] change MonochromeJpegError to JpegColorspaceError and add check for jpegs with alpha channel --- src/img2pdf.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/img2pdf.py b/src/img2pdf.py index 9c7c1ef..967e7e3 100755 --- a/src/img2pdf.py +++ b/src/img2pdf.py @@ -86,7 +86,7 @@ class ImageOpenError(Exception): pass -class MonochromeJpegError(Exception): +class JpegColorspaceError(Exception): pass @@ -616,9 +616,11 @@ def read_images(rawdata, colorspace, first_frame_only=False): color, ndpi, imgwidthpx, imgheightpx = get_imgmetadata( imgdata, imgformat, default_dpi, colorspace, rawdata) if color == Colorspace['1']: - raise MonochromeJpegError("jpeg can't be monochrome") + raise JpegColorspaceError("jpeg can't be monochrome") if color == Colorspace['P']: - raise MonochromeJpegError("jpeg can't have a color palette") + raise JpegColorspaceError("jpeg can't have a color palette") + if color == Colorspace['RGBA']: + raise JpegColorspaceError("jpeg can't have an alpha channel") im.close() return [(color, ndpi, imgformat, rawdata, imgwidthpx, imgheightpx)] else: