Page 1 of 1

Best way to create thumbs

Posted: 2013-05-13T16:23:00-07:00
by forumwt
Hello

I have a tube site and im using this function to generate thumbs from video file

Code: Select all

$thumbwidth = 240; //thumb width
$thumbheight = 180; //thumb height

$imagick_command = "-modulate 110,102,100 -sharpen 1x1 -enhance";

shell_exec("$ffmpeg_path -ss $first -i \"".$row[file]."\" -vcodec mjpeg -vframes 1 -an -f rawvideo -s ".$thumbwidth."x".$thumbheight." \"$image\"");

shell_exec("/usr/local/bin/mogrify $imagick_command $image"); 
Here is thumbs result, this image is just what i need, no border and etc..

Image

but sometimes depending on video i have thumbs like this

Image

Whats the best way to remove this black space from thumbs, but need to keep thumb size 240x180

Re: Best way to create thumbs

Posted: 2013-05-13T18:28:47-07:00
by fmw42
You will have to live with the black if you want to keep the size the same, unless you trim the black and then resize to fill the vertical dimension and then crop the excess from the horizontal. You can also trim and resize to the exact dimensions you want, but then the image will be distorted because it does not then keep the aspect ratio.

The problem may be that you are extracting a frame from an animation that has been optimized. You may want to coalesce the animation frame(s) before making thumbnails.

see
http://www.imagemagick.org/Usage/anim_basics/#coalesced
http://www.imagemagick.org/Usage/anim_mods/#mods
http://www.imagemagick.org/Usage/anim_opt/
http://www.imagemagick.org/Usage/anim_basics/