SWF thumbnails: support for gnash

Swfrender produced mostly black squares. Gnash handles SWF files much, much
better than swfrender.
This commit is contained in:
Marcin Kurczewski 2013-10-27 19:27:25 +01:00
parent bddf04ea78
commit 0d360d525e

View file

@ -673,14 +673,25 @@ class PostController
break; break;
case 'application/x-shockwave-flash': case 'application/x-shockwave-flash':
$srcImage = null; $srcImage = null;
exec('which swfrender', $tmp, $exitCode); exec('which dump-gnash', $tmp, $exitCode);
if ($exitCode == 0) if ($exitCode == 0)
{ {
$tmpPath = tempnam(sys_get_temp_dir(), 'thumb') . '.png'; $tmpPath = tempnam(sys_get_temp_dir(), 'thumb') . '.png';
exec('swfrender ' . $srcPath . ' -o ' . $tmpPath); exec('dump-gnash --screenshot last --screenshot-file ' . $tmpPath . ' -1 -r1 --max-advances 15 ' . $srcPath);
if (file_exists($tmpPath)) if (file_exists($tmpPath))
$srcImage = imagecreatefrompng($tmpPath); $srcImage = imagecreatefrompng($tmpPath);
} }
if (!$srcImage)
{
exec('which swfrender', $tmp, $exitCode);
if ($exitCode == 0)
{
$tmpPath = tempnam(sys_get_temp_dir(), 'thumb') . '.png';
exec('swfrender ' . $srcPath . ' -o ' . $tmpPath);
if (file_exists($tmpPath))
$srcImage = imagecreatefrompng($tmpPath);
}
}
break; break;
default: default:
break; break;