'--resize')
parser.add_argument(
'--size',
- nargs=2)
+ nargs=2,
+ type=int)
parser.add_argument(
'--initial_processing',
action='store_true')
if entry_args.state == 'failed':
if reprocess_args.resize:
raise Exception(_('You can not run --resize on media that has not'
- 'been processed.'))
+ ' been processed.'))
if reprocess_args.size:
_log.warn('With --initial_processing, the --size flag will be'
' ignored.')
if entry_args.state == 'processing':
raise Exception(_('We currently do not support reprocessing on media'
- 'that is in the "processing" state.'))
+ ' that is in the "processing" state.'))
def media_reprocess(args):
# For now we can only reprocess with the original file
if not entry.media_files.get('original'):
raise Exception(_('The original file for this media entry'
- 'does not exist.'))
+ ' does not exist.'))
reprocess_info = {'resize': reprocess_args.resize}
- if reprocess_args.size and len(reprocess_args.size) == 2:
+ if reprocess_args.size:
reprocess_info['max_width'] = reprocess_args.size[0]
reprocess_info['max_height'] = reprocess_args.size[1]
- run_process_media(entry, reprocess_info)
+ run_process_media(entry, reprocess_info=reprocess_info)
else:
raise Exception(_('The --resize flag must set either "thumb"'
proc_state.store_public(keyname, tmp_resized_filename, target_name)
-def resize_tool(proc_state, force, keyname, target_name,
+def resize_tool(proc_state, force, keyname, filename, target_name,
conversions_subdir, exif_tags, new_size=None):
- # filename -- the filename of the original image being resized
- filename = proc_state.get_queued_filename()
if not new_size:
max_width = mgg.global_config['media:' + keyname]['max_width']
max_height = mgg.global_config['media:' + keyname]['max_height']
except IOError:
raise BadMediaFail()
if force \
- or im.size[0] > max_width \
- or im.size[1] > max_height \
+ or im.size[0] > new_size[0]\
+ or im.size[1] > new_size[1]\
or exif_image_needs_rotation(exif_tags):
resize_image(
proc_state, im, unicode(keyname), target_name,
"""
entry = proc_state.entry
workbench = proc_state.workbench
- import ipdb
- ipdb.set_trace()
+
# Conversions subdirectory to avoid collisions
conversions_subdir = os.path.join(
workbench.dir, 'conversions')
gps_data = get_gps_data(exif_tags)
# Always create a small thumbnail
- resize_tool(proc_state, True, 'thumb',
+ resize_tool(proc_state, True, 'thumb', queued_filename,
name_builder.fill('{basename}.thumbnail{ext}'),
conversions_subdir, exif_tags)
# Possibly create a medium
- resize_tool(proc_state, False, 'medium',
+ resize_tool(proc_state, False, 'medium', queued_filename,
name_builder.fill('{basename}.medium{ext}'),
conversions_subdir, exif_tags)
if reprocess_info.get('max_width'):
max_width = reprocess_info['max_width']
+ max_height = reprocess_info['max_height']
else:
max_width = mgg.global_config \
['media:' + reprocess_info['resize']]['max_width']
-
- if reprocess_info.get('max_height'):
- max_height = reprocess_info['max_height']
- else:
max_height = mgg.global_config \
['media:' + reprocess_info['resize']]['max_height']
new_size = (max_width, max_height)
- resize_tool(proc_state, False, reprocess_info['resize'],
+ resize_tool(proc_state, False, reprocess_info['resize'], reprocess_filename,
name_builder.fill('{basename}.thumbnail{ext}'),
conversions_subdir, exif_tags, new_size)