Remove unused image processing parameters
This change removes the autoconvert and format parameters. In all call situations they were either not set or set to the default value anyway.
This commit is contained in:
@@ -290,14 +290,14 @@ def process_image(filepath, outpath, settings):
|
||||
shutil.copy(filepath, join(outpath, settings['orig_dir'], filename))
|
||||
|
||||
sigal.image.generate_image(
|
||||
filepath, outname, settings['img_size'], None, options=options,
|
||||
filepath, outname, settings['img_size'], options=options,
|
||||
copyright_text=settings['copyright'], method=settings['img_processor'],
|
||||
copy_exif_data=settings['copy_exif_data'])
|
||||
|
||||
if settings['make_thumbs']:
|
||||
thumb_name = join(outpath, get_thumb(settings, filename))
|
||||
sigal.image.generate_thumbnail(
|
||||
outname, thumb_name, settings['thumb_size'], None,
|
||||
outname, thumb_name, settings['thumb_size'],
|
||||
fit=settings['thumb_fit'], options=options)
|
||||
|
||||
|
||||
|
||||
@@ -32,8 +32,8 @@ from pilkit.utils import save_image
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
def generate_image(source, outname, size, format, options=None,
|
||||
autoconvert=True, copyright_text='', method='ResizeToFit',
|
||||
def generate_image(source, outname, size, options=None,
|
||||
copyright_text='', method='ResizeToFit',
|
||||
copy_exif_data=True):
|
||||
"""Image processor, rotate and resize the image.
|
||||
|
||||
@@ -71,12 +71,12 @@ def generate_image(source, outname, size, format, options=None,
|
||||
if copyright_text:
|
||||
add_copyright(img, copyright_text)
|
||||
|
||||
format = format or img.format or original_format or 'JPEG'
|
||||
logger.debug(u'Save resized image to {0} ({1})'.format(outname, format))
|
||||
save_image(img, outname, format, options=options, autoconvert=autoconvert)
|
||||
outformat = img.format or original_format or 'JPEG'
|
||||
logger.debug(u'Save resized image to {0} ({1})'.format(outname, outformat))
|
||||
save_image(img, outname, outformat, options=options, autoconvert=True)
|
||||
|
||||
|
||||
def generate_thumbnail(source, outname, box, format, fit=True, options=None):
|
||||
def generate_thumbnail(source, outname, box, fit=True, options=None):
|
||||
"Create a thumbnail image"
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -88,9 +88,9 @@ def generate_thumbnail(source, outname, box, format, fit=True, options=None):
|
||||
else:
|
||||
img.thumbnail(box, PILImage.ANTIALIAS)
|
||||
|
||||
format = format or img.format or original_format or 'JPEG'
|
||||
logger.debug(u'Save thumnail image to {0} ({1})'.format(outname, format))
|
||||
save_image(img, outname, format, options=options, autoconvert=True)
|
||||
outformat = img.format or original_format or 'JPEG'
|
||||
logger.debug(u'Save thumnail image to {0} ({1})'.format(outname, outformat))
|
||||
save_image(img, outname, outformat, options=options, autoconvert=True)
|
||||
|
||||
|
||||
def add_copyright(img, text):
|
||||
|
||||
@@ -86,7 +86,7 @@ def generate_video(source, outname, size, options={}):
|
||||
stderr=devnull)
|
||||
|
||||
|
||||
def generate_thumbnail(source, outname, box, format, fit=True, options=None):
|
||||
def generate_thumbnail(source, outname, box, fit=True, options=None):
|
||||
"Create a thumbnail image"
|
||||
# 1) dump an image of the video
|
||||
tmpfile = outname + ".tmp.jpg"
|
||||
@@ -94,6 +94,6 @@ def generate_thumbnail(source, outname, box, format, fit=True, options=None):
|
||||
subprocess.call(['ffmpeg', '-i', source, '-an', '-r', '1',
|
||||
'-vframes', '1', '-y', tmpfile], stderr=devnull)
|
||||
# 2) use the generate_thumbnail function from sigal.image
|
||||
sigal.image.generate_thumbnail(tmpfile, outname, box, format, fit, options)
|
||||
sigal.image.generate_thumbnail(tmpfile, outname, box, fit, options)
|
||||
# 3) remove the image
|
||||
os.unlink(tmpfile)
|
||||
|
||||
@@ -181,11 +181,11 @@ class Writer(object):
|
||||
if ext in self.settings['img_ext_list']:
|
||||
sigal.image.generate_thumbnail(
|
||||
source, thumb_path, self.settings['thumb_size'],
|
||||
None, fit=self.settings['thumb_fit'])
|
||||
fit=self.settings['thumb_fit'])
|
||||
else:
|
||||
sigal.video.generate_thumbnail(
|
||||
source, thumb_path, self.settings['thumb_size'],
|
||||
None, fit=self.settings['thumb_fit'])
|
||||
fit=self.settings['thumb_fit'])
|
||||
|
||||
ctx['albums'].append({
|
||||
'url': d + '/' + self.url_ext,
|
||||
|
||||
@@ -17,7 +17,7 @@ def test_generate_image(tmpdir):
|
||||
|
||||
dstfile = str(tmpdir.join(TEST_IMAGE))
|
||||
for size in [(600, 600), (300, 200)]:
|
||||
generate_image(SRCFILE, dstfile, size, None, method='ResizeToFill')
|
||||
generate_image(SRCFILE, dstfile, size, method='ResizeToFill')
|
||||
im = Image.open(dstfile)
|
||||
assert im.size == size
|
||||
|
||||
@@ -28,8 +28,7 @@ def test_generate_image_processor(tmpdir):
|
||||
init_logging()
|
||||
dstfile = str(tmpdir.join(TEST_IMAGE))
|
||||
with pytest.raises(SystemExit):
|
||||
generate_image(SRCFILE, dstfile, (200, 200), None,
|
||||
method='WrongMethod')
|
||||
generate_image(SRCFILE, dstfile, (200, 200), method='WrongMethod')
|
||||
|
||||
|
||||
def test_generate_thumbnail(tmpdir):
|
||||
@@ -37,13 +36,13 @@ def test_generate_thumbnail(tmpdir):
|
||||
|
||||
dstfile = str(tmpdir.join(TEST_IMAGE))
|
||||
for size in [(200, 150), (150, 200)]:
|
||||
generate_thumbnail(SRCFILE, dstfile, size, None)
|
||||
generate_thumbnail(SRCFILE, dstfile, size)
|
||||
im = Image.open(dstfile)
|
||||
assert im.size == size
|
||||
|
||||
for size, thumb_size in [((200, 150), (185, 150)),
|
||||
((150, 200), (150, 122))]:
|
||||
generate_thumbnail(SRCFILE, dstfile, size, None, fit=False)
|
||||
generate_thumbnail(SRCFILE, dstfile, size, fit=False)
|
||||
im = Image.open(dstfile)
|
||||
assert im.size == thumb_size
|
||||
|
||||
@@ -56,11 +55,11 @@ def test_exif_copy(tmpdir):
|
||||
test_image)
|
||||
dst_file = str(tmpdir.join(test_image))
|
||||
|
||||
generate_image(src_file, dst_file, (300, 400), None, copy_exif_data=True)
|
||||
generate_image(src_file, dst_file, (300, 400), copy_exif_data=True)
|
||||
raw, simple = get_exif_tags(dst_file)
|
||||
assert simple['iso'] == 50
|
||||
|
||||
generate_image(src_file, dst_file, (300, 400), None, copy_exif_data=False)
|
||||
generate_image(src_file, dst_file, (300, 400), copy_exif_data=False)
|
||||
raw, simple = get_exif_tags(dst_file)
|
||||
assert not raw
|
||||
assert not simple
|
||||
|
||||
Reference in New Issue
Block a user