diff --git a/mediagoblin/config_spec.ini b/mediagoblin/config_spec.ini
index f769e4e..04519d2 100644
a
|
b
|
max_height = integer(default=640)
|
144 | 144 | max_width = integer(default=180) |
145 | 145 | max_height = integer(default=180) |
146 | 146 | |
| 147 | [media:share] |
| 148 | # Dimensions used when creating media thumbnails for social media shareing |
| 149 | max_width = integer(default=600) |
| 150 | max_height = integer(default=315) |
| 151 | |
147 | 152 | [celery] |
148 | 153 | # default result stuff |
149 | 154 | CELERY_RESULT_BACKEND = string(default="database") |
diff --git a/mediagoblin/media_types/video/processing.py b/mediagoblin/media_types/video/processing.py
index a85b232..29758c9 100644
a
|
b
|
class CommonVideoProcessor(MediaProcessor):
|
215 | 215 | elif keyname == 'thumb': |
216 | 216 | if kwargs.get('thumb_size') != file_metadata.get('thumb_size'): |
217 | 217 | skip = False |
| 218 | elif keyname == 'share': |
| 219 | if kwargs.get('share_size') != file_metadata.get('share_size'): |
| 220 | skip = False |
218 | 221 | |
219 | 222 | return skip |
220 | 223 | |
… |
… |
class CommonVideoProcessor(MediaProcessor):
|
298 | 301 | width=dst_dimensions[0], |
299 | 302 | height=dst_dimensions[1]) |
300 | 303 | |
301 | | def generate_thumb(self, thumb_size=None): |
| 304 | def generate_image(self, size=None, magic='thumb', fname='thumbnail'): |
302 | 305 | # Temporary file for the video thumbnail (cleaned up with workbench) |
303 | | tmp_thumb = os.path.join(self.workbench.dir, |
| 306 | tmp = os.path.join(self.workbench.dir, |
304 | 307 | self.name_builder.fill( |
305 | | '{basename}.thumbnail.jpg')) |
| 308 | '{basename}.%s.jpg' % fname)) |
306 | 309 | |
307 | | if not thumb_size: |
308 | | thumb_size = (mgg.global_config['media:thumb']['max_width'],) |
| 310 | if not size: |
| 311 | size = (mgg.global_config['media:%s' % magic]['max_width'],) |
309 | 312 | |
310 | | if self._skip_processing('thumb', thumb_size=thumb_size): |
311 | | return |
| 313 | # How can this be more clever? |
| 314 | if magic == 'thumb': |
| 315 | if self._skip_processing(magic, thumb_size=size): |
| 316 | return |
| 317 | if magic == 'share': |
| 318 | if self._skip_processing(magic, share_size=size): |
| 319 | return |
312 | 320 | |
313 | 321 | # We will only use the width so that the correct scale is kept |
314 | 322 | transcoders.capture_thumb( |
315 | 323 | self.process_filename, |
316 | | tmp_thumb, |
317 | | thumb_size[0]) |
| 324 | tmp, |
| 325 | size[0]) |
318 | 326 | |
319 | 327 | # Checking if the thumbnail was correctly created. If it was not, |
320 | 328 | # then just give up. |
321 | | if not os.path.exists (tmp_thumb): |
| 329 | if not os.path.exists (tmp): |
322 | 330 | return |
323 | 331 | |
324 | 332 | # Push the thumbnail to public storage |
325 | | _log.debug('Saving thumbnail...') |
326 | | store_public(self.entry, 'thumb', tmp_thumb, |
327 | | self.name_builder.fill('{basename}.thumbnail.jpg')) |
| 333 | _log.debug('Saving image (%s)...' % magic) |
| 334 | store_public(self.entry, magic, tmp, |
| 335 | self.name_builder.fill('{basename}.%s.jpg' % fname)) |
328 | 336 | |
329 | | self.entry.set_file_metadata('thumb', thumb_size=thumb_size) |
| 337 | if magic == 'thumb': |
| 338 | self.entry.set_file_metadata(magic, thumb_size=size) |
| 339 | if magic == 'share': |
| 340 | self.entry.set_file_metadata(magic, share_size=size) |
330 | 341 | |
331 | 342 | class InitialProcessor(CommonVideoProcessor): |
332 | 343 | """ |
… |
… |
class InitialProcessor(CommonVideoProcessor):
|
375 | 386 | metavar=('max_width', 'max_height'), |
376 | 387 | type=int) |
377 | 388 | |
| 389 | parser.add_argument( |
| 390 | '--share_size', |
| 391 | nargs=2, |
| 392 | metavar=('max_width', 'max_height'), |
| 393 | type=int) |
| 394 | |
378 | 395 | return parser |
379 | 396 | |
380 | 397 | @classmethod |
381 | 398 | def args_to_request(cls, args): |
382 | 399 | return request_from_args( |
383 | 400 | args, ['medium_size', 'vp8_quality', 'vp8_threads', |
384 | | 'vorbis_quality', 'thumb_size']) |
| 401 | 'vorbis_quality', 'thumb_size', 'share_size']) |
385 | 402 | |
386 | 403 | def process(self, medium_size=None, vp8_threads=None, vp8_quality=None, |
387 | | vorbis_quality=None, thumb_size=None): |
| 404 | vorbis_quality=None, thumb_size=None, share_size=None): |
388 | 405 | self.common_setup() |
389 | 406 | |
390 | 407 | self.transcode(medium_size=medium_size, vp8_quality=vp8_quality, |
391 | 408 | vp8_threads=vp8_threads, vorbis_quality=vorbis_quality) |
392 | 409 | |
393 | 410 | self.copy_original() |
394 | | self.generate_thumb(thumb_size=thumb_size) |
| 411 | self.generate_image(size=thumb_size) |
| 412 | self.generate_image(size=share_size, magic='share', fname='share') |
395 | 413 | self.delete_queue_file() |
396 | 414 | |
397 | 415 | |
… |
… |
class Resizer(CommonVideoProcessor):
|
400 | 418 | Video thumbnail resizing process steps for processed media |
401 | 419 | """ |
402 | 420 | name = 'resize' |
403 | | description = 'Resize thumbnail' |
| 421 | description = 'Resize thumbnails and other images' |
404 | 422 | thumb_size = 'thumb_size' |
| 423 | share_size = 'share_size' |
405 | 424 | |
406 | 425 | @classmethod |
407 | 426 | def media_is_eligible(cls, entry=None, state=None): |
… |
… |
class Resizer(CommonVideoProcessor):
|
421 | 440 | metavar=('max_width', 'max_height'), |
422 | 441 | type=int) |
423 | 442 | |
| 443 | parser.add_argument( |
| 444 | '--share_size', |
| 445 | nargs=2, |
| 446 | metavar=('max_width', 'max_height'), |
| 447 | type=int) |
| 448 | |
424 | 449 | # Needed for gmg reprocess thumbs to work |
425 | 450 | parser.add_argument( |
426 | 451 | 'file', |
… |
… |
class Resizer(CommonVideoProcessor):
|
433 | 458 | @classmethod |
434 | 459 | def args_to_request(cls, args): |
435 | 460 | return request_from_args( |
436 | | args, ['thumb_size', 'file']) |
| 461 | args, ['thumb_size', 'share_size', 'file']) |
437 | 462 | |
438 | | def process(self, thumb_size=None, file=None): |
| 463 | def process(self, thumb_size=None, share_size=None, file=None): |
439 | 464 | self.common_setup() |
440 | | self.generate_thumb(thumb_size=thumb_size) |
| 465 | self.generate_image(size=thumb_size) |
| 466 | self.generate_image(size=share_size, magic='share', fname='share') |
441 | 467 | |
442 | 468 | |
443 | 469 | class Transcoder(CommonVideoProcessor): |