diff --git a/my_plugins/photos/__init__.py b/my_plugins/photos/__init__.py index 2dcf4ae2767fe6c2c9d29fe77ee5aaba1a41144e..f380cefb6c04db8e5d4066d190e1cf7df849b0f8 100644 --- a/my_plugins/photos/__init__.py +++ b/my_plugins/photos/__init__.py @@ -50,7 +50,6 @@ def initialized(pelican): DEFAULT_CONFIG.setdefault('VIDEO_COPY_JOBS', 1) DEFAULT_CONFIG.setdefault('PHOTO_EXIF_KEEP', False) DEFAULT_CONFIG.setdefault('PHOTO_EXIF_REMOVE_GPS', False) - DEFAULT_CONFIG.setdefault('PHOTO_EXIF_AUTOROTATE', True) DEFAULT_CONFIG.setdefault('PHOTO_EXIF_COPYRIGHT', False) DEFAULT_CONFIG.setdefault('PHOTO_EXIF_COPYRIGHT_AUTHOR', DEFAULT_CONFIG['SITENAME']) DEFAULT_CONFIG.setdefault('PHOTO_LIGHTBOX_GALLERY_ATTR', 'data-lightbox') @@ -72,7 +71,6 @@ def initialized(pelican): pelican.settings.setdefault('VIDEO_COPY_JOBS', 1) pelican.settings.setdefault('PHOTO_EXIF_KEEP', False) pelican.settings.setdefault('PHOTO_EXIF_REMOVE_GPS', False) - pelican.settings.setdefault('PHOTO_EXIF_AUTOROTATE', True) pelican.settings.setdefault('PHOTO_EXIF_COPYRIGHT', False) pelican.settings.setdefault('PHOTO_EXIF_COPYRIGHT_AUTHOR', pelican.settings['AUTHOR']) pelican.settings.setdefault('PHOTO_LIGHTBOX_GALLERY_ATTR', 'data-lightbox') @@ -125,29 +123,6 @@ def enqueue_copy(orig, copied): .format(copied, DEFAULT_CONFIG['queue_copy'][copied], orig)) - -def rotate_image(img, exif_dict): - - if "exif" in img.info and piexif.ImageIFD.Orientation in exif_dict["0th"]: - orientation = exif_dict["0th"].pop(piexif.ImageIFD.Orientation) - if orientation == 2: - img = img.transpose(Image.FLIP_LEFT_RIGHT) - elif orientation == 3: - img = img.rotate(180) - elif orientation == 4: - img = img.rotate(180).transpose(Image.FLIP_LEFT_RIGHT) - elif orientation == 5: - img = img.rotate(-90).transpose(Image.FLIP_LEFT_RIGHT) - elif orientation == 6: - img = img.rotate(-90, expand=True) - elif orientation == 7: - img = img.rotate(90).transpose(Image.FLIP_LEFT_RIGHT) - elif orientation == 8: - img = img.rotate(90) - - return (img, exif_dict) - - def manipulate_exif(img, settings): try: @@ -156,9 +131,6 @@ def manipulate_exif(img, settings): logger.debug('EXIF information not found') exif = {} - if settings['PHOTO_EXIF_AUTOROTATE']: - img, exif = rotate_image(img, exif) - if settings['PHOTO_EXIF_REMOVE_GPS']: exif.pop('GPS') @@ -169,13 +141,11 @@ def resize_worker(orig, resized, spec, settings): logger.info('photos: make photo {} -> {}'.format(orig, resized)) im = Image.open(orig) - - if ispiexif and settings['PHOTO_EXIF_KEEP'] and im.format == 'JPEG': - # Only works with JPEG exif for sure. + if ispiexif and settings['PHOTO_EXIF_KEEP'] and im.format in ('JPEG', 'MPO'): try: im, exif_copy = manipulate_exif(im, settings) - except Exception: - logger.info('photos: no EXIF or EXIF error in {}'.format(orig)) + except Exception as e: + logger.info('photos: no EXIF or EXIF error in {}:\n{}'.format(orig, e)) exif_copy = b'' else: exif_copy = b'' diff --git a/pelicanconf.py b/pelicanconf.py index a2a2cfde7044d591d1ac7177a7c340bfe2b448ff..40af0177e851d5fe67203d1aaaeb3a1501f3d6c5 100644 --- a/pelicanconf.py +++ b/pelicanconf.py @@ -14,8 +14,10 @@ PLUGINS = ['advthumbnailer', 'photos'] # Photos PHOTO_LIBRARY = "photos" -PHOTO_GALLERY = (3840, 2160, 80) -PHOTO_ARTICLE = (3840, 2160, 80) +PHOTO_GALLERY = (3840, 2160, 90) +PHOTO_ARTICLE = (3840, 2160, 90) +PHOTO_THUMB = (384, 256, 90) +PHOTO_EXIF_KEEP = True PHOTO_RESIZE_JOBS = 8 MARKDOWN = {'extensions': ['toc(permalink=🔗)', 'codehilite(linenums=False)', 'extra']} diff --git a/requirements.txt b/requirements.txt index b2e16ac221473df877c16b0c89dfcf182dc86fc8..58ccf8059fd8dc994dc7c91bf49bbc9cf5b5c398 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,4 +4,4 @@ Markdown==2.6.6 pelican-advthumbnailer==0.7.0 pelican-webassets==1.0.0 piexif==1.1.3 -Pillow==5.0.0 +Pillow==7.2.0 diff --git a/theme/css/style.css b/theme/css/style.css index 37a445e6c360c25b17b050c58af3f8a69a0c3bde..d9fd0062f3b597b252fd90c1e7f828aff810528a 100644 --- a/theme/css/style.css +++ b/theme/css/style.css @@ -362,6 +362,13 @@ main li { } +/********** Gallery **********/ +.gallery img { + max-width: 192px; + max-height: 128px; +} + + /********** Footer **********/ body > footer { text-align: center;