Browse Source

Remove the copy exif feature.

This feature was not really needed as the exif metadata were just copied to the
generated image. Moreover, this was depending on pyexiv2 which is now deprecated
in favour of GExiv2.
pull/17/merge
Simon 13 years ago
parent
commit
57eb9cf456
  1. 1
      docs/index.rst
  2. 7
      sigal/gallery.py
  3. 19
      sigal/image.py
  4. 8
      sigal/settings.py
  5. 3
      sigal/templates/sigal.conf.py
  6. 1
      tests/sample/sigal.conf.py
  7. 32
      tests/test_image.py

1
docs/index.rst

@ -58,7 +58,6 @@ Dependencies
- Jinja2
- Python Imaging Library (PIL / Pillow)
- Python Markdown
- pyexiv2 (optional, used to copy exif metadatas)
How to Use

7
sigal/gallery.py

@ -33,7 +33,7 @@ from multiprocessing import Pool
from os.path import join
from PIL import Image as PILImage
from .image import Image, copy_exif
from .image import Image
from .settings import get_thumb
from .writer import Writer
@ -232,7 +232,7 @@ def worker_image(*args):
def process_image(filepath, outpath, settings):
"""Process one image: resize, create thumbnail, copy exif."""
"""Process one image: resize, create thumbnail."""
filename = os.path.split(filepath)[1]
outname = join(outpath, filename)
@ -256,9 +256,6 @@ def process_image(filepath, outpath, settings):
fit=settings['thumb_fit'],
quality=settings['jpg_options']['quality'])
if settings['copy_exif']:
copy_exif(filepath, outname)
def get_metadata(path):
""" Get album metadata from DESCRIPTION_FILE:

19
sigal/image.py

@ -138,22 +138,3 @@ class quiet(object):
os.dup2(self.old, self.stderr_fd)
os.close(self.null_fd)
os.close(self.old)
def copy_exif(srcfile, dstfile):
"Copy the exif metadatas from src to dest images"
logger = logging.getLogger(__name__)
import pyexiv2
src = pyexiv2.ImageMetadata(srcfile)
dst = pyexiv2.ImageMetadata(dstfile)
src.read()
dst.read()
try:
src.copy(dst)
except:
logger.error("metadata not copied for %s.", srcfile)
return
dst.write()

8
sigal/settings.py

@ -34,7 +34,6 @@ _DEFAULT_CONFIG = {
'keep_orig': False,
'orig_dir': 'original',
'jpg_options': {'quality': 85, 'optimize': True, 'progressive': True},
'copy_exif': False,
'copyright': '',
'ext_list': ['.jpg', '.jpeg', '.JPG', '.JPEG', '.png'],
'theme': 'colorbox',
@ -73,11 +72,4 @@ def read_settings(filename=None):
logger.warning("The %s setting should be specified with the "
"largest value first.", key)
if settings['copy_exif']:
try:
import pyexiv2 # NOQA
except ImportError:
settings['copy_exif'] = False
logger.error("Error: install pyexiv2 module to use exif metadatas")
return settings

3
sigal/templates/sigal.conf.py

@ -47,9 +47,6 @@ thumb_size = (280, 210)
# links = [('Example link', 'http://example.org'),
# ('Another link', 'http://example.org')]
# Keep exif metadatas in output image (default: False)
# copy_exif = True
# Add a copyright text on the image (default: '')
# copyright = "An example copyright message"

1
tests/sample/sigal.conf.py

@ -7,5 +7,4 @@ keep_orig = True
links = [('Example link', 'http://example.org'),
('Another link', 'http://example.org')]
copy_exif = True
copyright = "An example copyright message"

32
tests/test_image.py

@ -9,12 +9,7 @@ try:
except ImportError:
import unittest # NOQA
try:
import pyexiv2
except ImportError:
pyexiv2 = False
from sigal.image import copy_exif, Image
from sigal.image import Image
CURRENT_DIR = os.path.dirname(__file__)
TEST_IMAGE = 'exo20101028-b-full.jpg'
@ -38,28 +33,3 @@ class TestImage(unittest.TestCase):
def test_save(self):
self.img.save(self.dstfile)
self.assertTrue(os.path.isfile(self.dstfile))
@unittest.skipUnless(pyexiv2, "pyexiv2 isn't installed")
class TestExif(unittest.TestCase):
"Test the copy of exif metadata with pyexiv2."
def setUp(self):
self.temp_path = mkdtemp()
self.srcfile = os.path.join(CURRENT_DIR, 'sample', 'dir2', TEST_IMAGE)
self.dstfile = os.path.join(self.temp_path, TEST_IMAGE)
img = Image(self.srcfile)
img.save(self.dstfile)
copy_exif(self.srcfile, self.dstfile)
def tearDown(self):
rmtree(self.temp_path)
def test_exif(self):
src = pyexiv2.ImageMetadata(self.srcfile)
dst = pyexiv2.ImageMetadata(self.dstfile)
src.read()
dst.read()
self.assertListEqual(src.keys(), dst.keys())

Loading…
Cancel
Save