# HG changeset patch # User Matti Hamalainen # Date 1417269861 -7200 # Node ID 03b245ef3a4725a680613b4f7ff5507ddb2f26a3 # Parent 1e347288712ddb53ad389003c2df55085a93c442 Various fixes to previews generation. diff -r 1e347288712d -r 03b245ef3a47 faptool.php --- a/faptool.php Sat Nov 29 15:31:26 2014 +0200 +++ b/faptool.php Sat Nov 29 16:04:21 2014 +0200 @@ -10,12 +10,12 @@ -function wtConvertImage($inFilename, $inFileType, $outFilename, $setDim, $setFormat, $setQuality, $thumb) +function wtConvertImage($inFilename, $outFilename, $outDim, $outFormat, $outQuality, $thumb, $useGfxConv) { global $setPreviewPath; $isTemp = FALSE; - if ($inFileType == "gfx") + if ($useGfxConv) { // Oh great .. we need gfxconv here because Imagick handles ILBM like shit $tmpFilename = tempnam($setPreviewPath, "tmp"); @@ -35,9 +35,6 @@ else $tmpFilename = $inFilename; - // convert -resize 640x480 -background black -gravity center -extent 640x480 - // -unsharp "0x0.75+0.75+0.008" lol.lbm -quality 95 test.jpg - // Create conversion entity $img = new Imagick($tmpFilename); if ($img === false) @@ -46,15 +43,8 @@ return FALSE; } - if ($setDim !== FALSE) + if ($outDim !== FALSE) { - if (($outDim = stGetSetting($setDim)) === FALSE || - ($outFormat = stGetSetting($setFormat)) === FALSE || - ($outQuality = stGetSetting($setQuality)) === FALSE) - { - die("Missing one of res/format/quality settings for '".$outFilename."'\n"); - } - // Get dimensions, setup background $dim = $img->getImageGeometry(); // $img->setBackgroundColor(imagick::COLOR_BLACK); @@ -84,6 +74,7 @@ $img->stripImage(); $img->writeImage($outFilename); $img->removeImage(); + return TRUE; } @@ -111,12 +102,13 @@ $sduration = intval(stGetSetting("sampleDuration")); $schannels = intval(stGetSetting("sampleChannels")); + $optStr = ""; foreach ($outOpts as $okey => $oval) $optStr .= $okey." ".$oval." "; return wtExec( "/usr/local/bin/avconv", - "-y -t ".intval($sduration)." ". + "-y -v 1 -t ".intval($sduration)." ". "-i ".escapeshellarg($inFilename). " ".$optStr." -ac ".$schannels. " -map_metadata -1 ". @@ -157,9 +149,9 @@ case EFILE_IMAGE: $res = wtConvertImage( $inFilename, - $edata["mime"], $outFilename, - FALSE, "PNG", 9, FALSE); + FALSE, "PNG", 9, + FALSE, ($edata["mime"] == "gfx")); break; } @@ -202,6 +194,7 @@ wtPurgeDir($path); wtMakeDir($path, 0700); + $cwd = getcwd(); if (!is_dir($path) || chdir($path) === false) { echo "ERROR: Failed to chdir to '".$path."', can't unpack archive.\n"; @@ -209,7 +202,10 @@ } // Unpack archive - return wtExec($exe, $args); + $ret = wtExec($exe, $args); + + chdir($cwd); + return $ret; } @@ -305,10 +301,16 @@ $fname = $path."/".$dentry; // check file type against entry's preview_type // if match, render / convert / cp to as source and exit loop. - if (is_file($fname) && - ($mdata = stProbeFileInfo($fname, TRUE)) !== false && + if ($dentry != "." && $dentry != "..") + { + if (is_dir($fname)) + echo "XXX: ".$dentry." :: ".$fname."\n"; + else + if (is_file($fname) && + ($mdata = stProbeFileInfo($fname, TRUE)) !== false && ($found = wtEntryToSource($compo, $fname, $mdata, $filename, $pdata, $outFilename, $force)) === true) break; + } } // Cleanup @@ -367,17 +369,19 @@ case EFILE_IMAGE: wtConvertImage( $inFilename, - "png", $pdata["files"]["image"]["file"], - "previewImageSize", "previewImageType", - "previewImageQuality", FALSE); + stGetSetting("previewImageSize"), + stGetSetting("previewImageType"), + stGetSetting("previewImageQuality"), + FALSE, FALSE); wtConvertImage( $inFilename, - "png", $pdata["files"]["thumb"]["file"], - "previewThumbSize", "previewThumbType", - "previewThumbQuality", TRUE); + stGetSetting("previewThumbSize"), + stGetSetting("previewThumbType"), + stGetSetting("previewThumbQuality"), + TRUE, FALSE); break; } @@ -446,7 +450,7 @@ // function wtExec($exe, $args, $expect = 0) { - echo "EXEC: ".$exe." ".$args."\n"; + echo "EXEC: ".$exe." @ ".$args."\n"; exec(escapeshellcmd($exe)." ".$args, $output, $code); if ($code !== $expect) {