Feature parity with old thumbnails step (store failed attempts in the DB)
This commit is contained in:
2019-05-25 03:50:32 -07:00
parent 242d213a45
commit 02d81ab872
3 changed files with 14 additions and 11 deletions

View File

@@ -596,6 +596,8 @@ if ($p['thumbs']) {
$cmd['ffmpeg'] = $bin_ffmpeg." -ss $(( $(".$bin_mediainfo." --Inform='Video;%Duration%' ".$shellpath." | cut -d'.' -f1) / 10000 )) -i ".$shellpath." -vframes 1 -filter:v scale='400:-1' -q:v 3 ".$tfile;
$cmd['ql-thumbnail'] = $bin_qlthumb." ".$shellpath." ".$tfile." public.jpeg ".$p['thumb_size']." ".$p['thumb_size']." .8";
$cmd['qltool'] = $bin_qltool." di ".$shellpath." ".$p['thumb_size']." ".$p['thumb_size']." | base64 --decode | ".$bin_magick." convert - -resize 50% -strip -trim +repage -define png:compression-level=9 ".$tpfile;
// qltool thumbs are double size with half the pixels
// repage crops thumbs to edge (match sips/ffmpeg thumbs)
$cmd['qlmanage'] = "qlmanage -ti -f ".floor($p['thumb_size']/128)." -o /tmp/ ".$shellpath."; mv ".$tmp_path." ".$tpfile;
$cmd['vips'] = $bin_vips." ".$shellpath." -o ".$tfile."[Q=90,optimize_coding] --size=".$p['thumb_size'];
@@ -627,23 +629,26 @@ if ($p['thumbs']) {
break;
}
$stmt->BindValue(":fid",$fid);
$stmt->BindValue(":created",time());
// store the attempt in the DB so we don't try to generate thumbs for the same fid multiple times
foreach ($priority as $tool) {
if (@$cmd[$tool]) {
$stmt->BindValue(":tool",$tool);
shell_exec($cmd[$tool]." 2>&1");
msg($cmd[$tool]);
if (is_file($fmt[$tool]) && @filesize($fmt[$tool])) {
$stmt->BindValue(":fid",$fid);
$stmt->BindValue(":created",time());
$stmt->BindValue(":tool",$tool);
$stmt->BindValue(":relative_path",substr($fmt[$tool], strlen($bpath)));
list($width, $height) = getimagesize($fmt[$tool]);
$stmt->BindValue(":width",$width);
$stmt->BindValue(":height",$height);
$stmt->execute();
break;
}
}
}
$stmt->execute();
}