From ce68177ba0dc27010435e55b79cbea453751f8ee Mon Sep 17 00:00:00 2001 From: shadlaws Date: Tue, 18 Dec 2012 15:58:13 +0100 Subject: [#1928 - Make thumbnail generation more flexible for movies (graphics and movie helpers)] - graphics helper: add movie_extract_frame event to generate function (allows modules to add to the options sent to movie::extract_frame or to generate the thumbnail on their own without movie::extract_frame) - movie helper: add extra optional argument to movie::extract_frame (can add ffmpeg arguments and/or change the frame extract time) - gallery_installer: add movie_extract_time module variable, update to v53 - module.info: update to v53 - install.sql: update to v53 --- modules/gallery/helpers/graphics.php | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) (limited to 'modules/gallery/helpers/graphics.php') diff --git a/modules/gallery/helpers/graphics.php b/modules/gallery/helpers/graphics.php index c19fbe6d..c7f87403 100644 --- a/modules/gallery/helpers/graphics.php +++ b/modules/gallery/helpers/graphics.php @@ -155,13 +155,27 @@ class graphics_Core { try { foreach ($ops as $target => $output_file) { if ($input_item->is_movie()) { - // Convert the movie to a JPG first + // Convert the movie filename to a JPG first, delete anything that might already be there $output_file = legal_file::change_extension($output_file, "jpg"); - try { - movie::extract_frame($input_file, $output_file); - } catch (Exception $e) { - // Assuming this is MISSING_FFMPEG for now - copy(MODPATH . "gallery/images/missing_movie.jpg", $output_file); + unlink($output_file); + // Run movie_extract_frame events, which can either: + // - generate an output file, bypassing the ffmpeg-based movie::extract_frame + // - add to the options sent to movie::extract_frame (e.g. change frame extract time, + // add de-interlacing arguments to ffmpeg... see movie helper for more info) + // Note that the args are similar to those of the events in gallery_graphics + $movie_options_wrapper = new stdClass(); + $movie_options_wrapper->movie_options = array(); + module::event("movie_extract_frame", $input_file, $output_file, + $movie_options_wrapper, $input_item); + // If no output_file generated by events, run movie::extract_frame with movie_options + clearstatcache(); + if (@filesize($output_file) == 0) { + try { + movie::extract_frame($input_file, $output_file, $movie_options_wrapper->movie_options); + } catch (Exception $e) { + // Didn't work, likely because of MISSING_FFMPEG - copy missing_movie instead + copy(MODPATH . "gallery/images/missing_movie.jpg", $output_file); + } } $working_file = $output_file; } else { -- cgit v1.2.3 From ff6688b48b2eb083f82d803249f61dc08efb5b92 Mon Sep 17 00:00:00 2001 From: shadlaws Date: Tue, 1 Jan 2013 15:47:04 +0100 Subject: #1919 - change `convert -v` to `convert -version` --- modules/gallery/helpers/graphics.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules/gallery/helpers/graphics.php') diff --git a/modules/gallery/helpers/graphics.php b/modules/gallery/helpers/graphics.php index c7f87403..bfc0085d 100644 --- a/modules/gallery/helpers/graphics.php +++ b/modules/gallery/helpers/graphics.php @@ -335,7 +335,7 @@ class graphics_Core { // ImageMagick & GraphicsMagick $magick_kits = array( "imagemagick" => array( - "name" => "ImageMagick", "binary" => "convert", "version_arg" => "-v", + "name" => "ImageMagick", "binary" => "convert", "version_arg" => "-version", "version_regex" => "/Version: \S+ (\S+)/"), "graphicsmagick" => array( "name" => "GraphicsMagick", "binary" => "gm", "version_arg" => "version", -- cgit v1.2.3 From 9d684b7b83f0aa026e9d6f06228294f179a3bcaa Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Mon, 14 Jan 2013 12:52:47 -0500 Subject: Fix up some indentation. --- modules/gallery/helpers/graphics.php | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'modules/gallery/helpers/graphics.php') diff --git a/modules/gallery/helpers/graphics.php b/modules/gallery/helpers/graphics.php index bfc0085d..e7c5da68 100644 --- a/modules/gallery/helpers/graphics.php +++ b/modules/gallery/helpers/graphics.php @@ -166,7 +166,7 @@ class graphics_Core { $movie_options_wrapper = new stdClass(); $movie_options_wrapper->movie_options = array(); module::event("movie_extract_frame", $input_file, $output_file, - $movie_options_wrapper, $input_item); + $movie_options_wrapper, $input_item); // If no output_file generated by events, run movie::extract_frame with movie_options clearstatcache(); if (@filesize($output_file) == 0) { @@ -215,7 +215,7 @@ class graphics_Core { // Something went wrong rebuilding the image. Leave it dirty and move on. // @todo we should handle this better. Kohana_Log::add("error", "Caught exception rebuilding image: {$item->title}\n" . - $e->getMessage() . "\n" . $e->getTraceAsString()); + $e->getMessage() . "\n" . $e->getTraceAsString()); throw $e; } } @@ -274,13 +274,13 @@ class graphics_Core { $count = graphics::find_dirty_images_query()->count_records(); if ($count) { site_status::warning( - t2("One of your photos is out of date. Click here to fix it", - "%count of your photos are out of date. Click here to fix them", - $count, - array("attrs" => html::mark_clean(sprintf( - 'href="%s" class="g-dialog-link"', - url::site("admin/maintenance/start/gallery_task::rebuild_dirty_images?csrf=__CSRF__"))))), - "graphics_dirty"); + t2("One of your photos is out of date. Click here to fix it", + "%count of your photos are out of date. Click here to fix them", + $count, + array("attrs" => html::mark_clean(sprintf( + 'href="%s" class="g-dialog-link"', + url::site("admin/maintenance/start/gallery_task::rebuild_dirty_images?csrf=__CSRF__"))))), + "graphics_dirty"); } } @@ -334,12 +334,12 @@ class graphics_Core { } else { // ImageMagick & GraphicsMagick $magick_kits = array( - "imagemagick" => array( - "name" => "ImageMagick", "binary" => "convert", "version_arg" => "-version", - "version_regex" => "/Version: \S+ (\S+)/"), - "graphicsmagick" => array( - "name" => "GraphicsMagick", "binary" => "gm", "version_arg" => "version", - "version_regex" => "/\S+ (\S+)/")); + "imagemagick" => array( + "name" => "ImageMagick", "binary" => "convert", "version_arg" => "-version", + "version_regex" => "/Version: \S+ (\S+)/"), + "graphicsmagick" => array( + "name" => "GraphicsMagick", "binary" => "gm", "version_arg" => "version", + "version_regex" => "/\S+ (\S+)/")); // Loop through the kits foreach ($magick_kits as $index => $settings) { $path = system::find_binary( -- cgit v1.2.3