Mercurial > hg > fapweb
changeset 884:bc64949e7a97
Moar work.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 26 Nov 2014 17:43:13 +0200 |
parents | 782c42dfc465 |
children | 2ca7f609e480 |
files | faptool.php |
diffstat | 1 files changed, 79 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/faptool.php Wed Nov 26 17:04:55 2014 +0200 +++ b/faptool.php Wed Nov 26 17:43:13 2014 +0200 @@ -24,8 +24,53 @@ die("Missing one of res/format/quality settings for '".$outFilename."'\n"); } + if ($inFileType == "gfx") + { + // Oh great .. we need gfxconv here because Imagick handles ILBM like shit + $filename = tempnam($setPreviewPath, "tmp"); + wtExecOrDie( + "/usr/local/bin/gfxconv", + escapeshellarg($inFilename)." -f png -o ".escapeshellarg($filename)); + } + else + $filename = $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($filename); + if ($img === false) + die("Oh noes! ImageMagick could not digest the file '".$filename."' (".$inFilename.")\n"); + + // Get dimensions, setup background + $dim = $img->getImageGeometry(); + $img->setBackgroundColor(imagick::COLOR_BLACK); + $img->setGravity(imagick::GRAVITY_CENTER); + + // Act based on image size vs. desired size and $thumb mode + if ($thumb || $dim["width"] > $outDim[0] || $dim["height"] > $outDim[1]) + { + // Image is larger + $img->resizeImage($outDim[0], $outDim[1], Imagick::FILTER_QUADRATIC, 1); + $img->setExtent($outDim[0], $outDim[1]); + $img->normalizeImage(); + $img->unsharpMaskImage(0, 0.5, 1, 0.05); + } + else + if ($dim["width"] < $outDim[0] || $dim["height"] < $outDim[1]) + { + // Image is smaller than requested dimension(s)? + $img->resizeImage($outDim[0], $outDim[1], Imagick::FILTER_POINT, 1); + $img->setExtent($outDim[0], $outDim[1]); + } + + $img->setFormat($outFormat); + $img->setCompressionQuality($outQuality); + + $img->stripImage(); + $img->writeImage($outFilename); + $img->removeImage(); } @@ -35,6 +80,14 @@ $sduration = intval(stGetSetting("sampleDuration", 30)); $schannels = intval(stGetSetting("sampleChannels", 1)); + wtExecOrDie( + "/usr/local/bin/openmpt123", + + "--quiet --render ". + "--samplerate ".$sfreq." ". + "--channels ".$schannels." ". + "--playtime ".$sduration." ". + escapeshellarg($filename)." -o ".escapeshellarg($sampleFile)); } @@ -44,6 +97,22 @@ $sduration = intval(stGetSetting("sampleDuration", 30)); $schannels = intval(stGetSetting("sampleChannels", 1)); + // Convert to desired formats + // avconv -t 35 -i xxx_sample.wav -f ogg -c:a vorbis -b:a 95 -ac 1 -map_metadata -1 xxx_sample.ogg + $exe = "/usr/local/bin/avconv"; +/* + foreach (...) + { + $args = + "-y -t ".intval($sduration)." ". + "-i ".escapeshellarg($filename)." ". + + "-f ".$format." -c:a ".$codec." ".$qualityopt." ".$qualityvalue." ". + "-ac ".$schannels." ". + "-map_metadata -1 ". + escapeshellarg($outFilename); + } +*/ } @@ -131,6 +200,11 @@ } +function wtHandleEntry($compo, $entry, $mode) +{ +} + + // // Create directories // @@ -211,16 +285,16 @@ // Act according to specified command -switch (substr(stCArgLC(1), 0, 4)) +switch (substr(stCArgLC(1), 0, 3)) { - case "init": + case "ini": // // Initialize the data directories etc // stInitializeDirs(); break; - case "prev": + case "pre": // // Preview files handling // @@ -228,16 +302,14 @@ switch ($mode) { case "sta": - // List previews that are found and missing foreach (stExecSQL("SELECT * FROM compos WHERE cpath <> '' AND cpath IS NOT NULL") as $compo) { printf( "\n". "--[ #%03d - %-30s ]---\n". "PrevType : %s\n". - "PrevPath : %s\n". - "----------------------------------------------\n", - $compo["id"], $compo["name"], + "PrevPath : %s\n", + $compo["id"], substr($compo["name"], 0, 30), $previewTypeList[$compo["preview_type"]][0], stMakePath(FALSE, FALSE, array($setPreviewPath, $compo["cpath"])));