0.7.12.5 (Icons)
74
Yuba.php
@@ -7,6 +7,7 @@ $version = file_get_contents(__DIR__."/version.txt");
|
||||
|
||||
ini_set('memory_limit', '10240M');
|
||||
date_default_timezone_set("America/Los_Angeles");
|
||||
$mytime = time();
|
||||
|
||||
// Includes & Prefs
|
||||
//////////////////////////////////////////
|
||||
@@ -25,7 +26,7 @@ $p['phpbin'] = "/usr/bin/php";
|
||||
require("functions.php");
|
||||
require("filetypes.php");
|
||||
|
||||
$wopt_steps = 10;
|
||||
$wopt_steps = 12;
|
||||
$wopt_currstep = 1;
|
||||
|
||||
$parser = new plistParser();
|
||||
@@ -74,6 +75,7 @@ if (is_writable($zpath)) { echo "Warning: source is writeable\n"; }
|
||||
$bpath = chop($bdest,"/")."/".substr(crc32($zpath),0,3)."_".$blabel.".bundle";
|
||||
if (!is_dir($bpath)) { mkdir($bpath); }
|
||||
if (!is_dir($bpath."/thumbs")) { mkdir($bpath."/thumbs"); }
|
||||
if (!is_dir($bpath."/icons")) { mkdir($bpath."/icons"); }
|
||||
if (!is_dir($bpath."/contents")) { mkdir($bpath."/contents"); }
|
||||
|
||||
// Metadata tools
|
||||
@@ -86,6 +88,7 @@ $bin_qltool = __DIR__."/bin/qltool";
|
||||
$bin_magick = __DIR__."/bin/magick";
|
||||
$bin_sox = __DIR__."/bin/sox";
|
||||
$bin_pngcrush = __DIR__."/bin/pngcrush";
|
||||
$bin_parallel = __DIR__."/bin/parallel";
|
||||
$bin_vips = "vipsthumbnail";
|
||||
|
||||
// Logfile
|
||||
@@ -387,17 +390,19 @@ $dbp = new PDO("sqlite:".$bpath."/pool.sqlite3");
|
||||
|
||||
$dbp->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
|
||||
$dbp->query("PRAGMA page_size = 4096");
|
||||
$dbp->query("PRAGMA cache_size = 10000");
|
||||
$dbp->query("PRAGMA locking_mode = EXCLUSIVE");
|
||||
$dbp->query("PRAGMA synchronous = NORMAL");
|
||||
$dbp->query("PRAGMA journal_mode = WAL");
|
||||
//$dbp->query("PRAGMA page_size = 4096");
|
||||
//$dbp->query("PRAGMA cache_size = 10000");
|
||||
//$dbp->query("PRAGMA locking_mode = EXCLUSIVE");
|
||||
//$dbp->query("PRAGMA synchronous = NORMAL");
|
||||
//$dbp->query("PRAGMA journal_mode = WAL");
|
||||
|
||||
$dbp->exec("CREATE TABLE IF NOT EXISTS md5 (fid TEXT, hash TEXT)");
|
||||
$dbp->exec("CREATE TABLE IF NOT EXISTS exiftool (fid TEXT, tags TEXT)");
|
||||
$dbp->exec("CREATE TABLE IF NOT EXISTS mediainfo (fid TEXT, info TEXT)");
|
||||
$dbp->exec("CREATE TABLE IF NOT EXISTS thumbs (fid TEXT, created INTEGER, relative_path TEXT, width INTEGER, height INTEGER, tool TEXT)");
|
||||
$dbp->exec("CREATE TABLE IF NOT EXISTS icons (fid TEXT, hash TEXT, created INTEGER, relative_path TEXT, tool TEXT)");
|
||||
$dbp->exec("CREATE TABLE IF NOT EXISTS contents (fid TEXT, created INTEGER, relative_path TEXT)");
|
||||
$dbp->exec("CREATE TABLE IF NOT EXISTS counter (time INTEGER, pass TEXT, count INTEGER)");
|
||||
|
||||
// Prescan
|
||||
//////////////////////////////////////////
|
||||
@@ -465,6 +470,9 @@ foreach ($files as $splFileInfo) {
|
||||
|
||||
}
|
||||
|
||||
// Convert $fx to splFixedArray for performance (?)
|
||||
//$fx = SplFixedArray::fromArray($fx);
|
||||
|
||||
echo ProgressBar::finish();
|
||||
|
||||
// Thow permissions error
|
||||
@@ -540,13 +548,55 @@ $wopt_currstep++;
|
||||
//////////////////////////////////////////
|
||||
|
||||
echo ProgressBar::start(count($fx),"Searching for directory previews (".stepString().")");
|
||||
|
||||
foreach ($fx as $array) {
|
||||
$fid = $array[0];
|
||||
$pathname = $array[1];
|
||||
if (in_array(basename($pathname),$p['p_files'])) {
|
||||
$dpreview[dirname($pathname)] = $fid;
|
||||
}
|
||||
echo ProgressBar::next();
|
||||
}
|
||||
echo ProgressBar::finish();
|
||||
|
||||
// Icons Test
|
||||
//////////////////////////////////////////
|
||||
|
||||
$p['icons'] = 1;
|
||||
|
||||
if ($p['icons']) {
|
||||
|
||||
$stmt = $dbp->prepare("INSERT INTO counter VALUES (:time, :pass, :count)");
|
||||
$stmt->BindValue(":time",$mytime);
|
||||
$stmt->BindValue(":pass","icons");
|
||||
$stmt->BindValue(":count",0);
|
||||
$stmt->execute();
|
||||
|
||||
echo ProgressBar::start(count($fx),"Creating icon batch (".stepString().")");
|
||||
|
||||
if (!is_dir("/tmp/Yuba/")) { mkdir("/tmp/Yuba/"); }
|
||||
if (!is_dir("/tmp/Yuba/".$mytime)) { mkdir("/tmp/Yuba/".$mytime); }
|
||||
$batchfile = "/tmp/Yuba/".$mytime."/batch.sh";
|
||||
$helper = realpath("helper.php");
|
||||
|
||||
foreach ($fx as $array) {
|
||||
$fid = $array[0];
|
||||
$pathname = $array[1];
|
||||
$icmd = $p['phpbin']." ".$helper." icons ".$fid." ".escapeshellarg($pathname)." ".escapeshellarg($bpath)." ".$mytime;
|
||||
msg($icmd);
|
||||
$line[] = $icmd;
|
||||
echo ProgressBar::next();
|
||||
}
|
||||
file_put_contents($batchfile,implode("\n", $line));
|
||||
|
||||
echo ProgressBar::finish();
|
||||
|
||||
echo ProgressBar::start(count($fx),"Running icon batch (".stepString().")");
|
||||
echo ProgressBar::next();
|
||||
|
||||
passthru($bin_parallel." < ".$batchfile);
|
||||
|
||||
echo ProgressBar::finish();
|
||||
|
||||
}
|
||||
|
||||
// Thumbnails
|
||||
@@ -825,6 +875,7 @@ $dbp->exec("CREATE INDEX IF NOT EXISTS exiftool_index ON exiftool (fid)");
|
||||
$dbp->exec("CREATE INDEX IF NOT EXISTS md5_index ON md5 (fid)");
|
||||
$dbp->exec("CREATE INDEX IF NOT EXISTS mediainfo_index ON mediainfo (fid)");
|
||||
$dbp->exec("CREATE INDEX IF NOT EXISTS thumbs_index ON thumbs (fid)");
|
||||
$dbp->exec("CREATE INDEX IF NOT EXISTS icons_index ON icons (fid)");
|
||||
|
||||
// Spotlight
|
||||
//////////////////////////////////////////
|
||||
@@ -1090,7 +1141,7 @@ foreach ($files as $splFileInfo) {
|
||||
|
||||
} elseif ($type == "dir") {
|
||||
|
||||
if (is_array($dpreview) && $dpreview[$pathname]) {
|
||||
if (@is_array($dpreview) && $dpreview[$pathname]) {
|
||||
$fetch_thumb = $dbp->query("SELECT * FROM thumbs WHERE fid='".$dpreview[$pathname]."'")->fetch();
|
||||
if (@$fetch_thumb['relative_path']) {
|
||||
$stmt->BindValue(":thumb_filename",$fetch_thumb['relative_path']);
|
||||
@@ -1238,7 +1289,7 @@ while ($row_a = $loop->fetch()) {
|
||||
$m['m']['SkimTrackCount'] = @count($m_base);
|
||||
foreach (@$m_base as $track) {
|
||||
if (!@$m['m']['SkimDims'] && @$track['Width'] && @$track['Height']) {
|
||||
$m['m']['SkimDims'] = sanitize($track['Width'],"i").$display_delimiter.sanitize($track['Height'],"i");
|
||||
$m['m']['SkimDims'] = @sanitize($track['Width'],"i").$display_delimiter.@sanitize($track['Height'],"i");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1279,7 +1330,7 @@ while ($row_a = $loop->fetch()) {
|
||||
// find a single value
|
||||
list($kind,$item) = explode("^",$dindex);
|
||||
if (@$m[$kind][$item]) {
|
||||
$stmt->BindValue(":".$name,sanitize($m[$kind][$item],$type));
|
||||
$stmt->BindValue(":".$name,@sanitize($m[$kind][$item],$type));
|
||||
$found = 1;
|
||||
}
|
||||
|
||||
@@ -1322,7 +1373,8 @@ if ($p['postflight'] == 2 && $p['rsync_dest']) {
|
||||
}
|
||||
|
||||
$done = "Finished ".$zpath." in ".$seconds." seconds";
|
||||
echo msg($done); notification($done);
|
||||
$done_m = "Memory usage: ".prettysize(memory_get_usage(true));
|
||||
echo msg($done."\n".$done_m); notification($done);
|
||||
|
||||
unset($dbo, $dbp, $files, $family, $fx);
|
||||
|
||||
|
||||
@@ -67,6 +67,11 @@ class ProgressBar {
|
||||
// Functions
|
||||
//////////////////////////////////////////
|
||||
|
||||
function prettysize($size) {
|
||||
$unit=array('b','kb','mb','gb','tb','pb');
|
||||
return @round($size/pow(1024,($i=floor(log($size,1024)))),2).' '.$unit[$i];
|
||||
}
|
||||
|
||||
function alert($string, $title = "Warning") {
|
||||
echo "\nALERT:".$title."|".$string."\n";
|
||||
}
|
||||
|
||||
64
helper.php
Executable file
@@ -0,0 +1,64 @@
|
||||
<?
|
||||
|
||||
// Yuba batch helper
|
||||
// //
|
||||
//////////////////////////////////////////
|
||||
|
||||
$prefs_file = "/Users/".get_current_user()."/Library/Preferences/yuba_prefs.php";
|
||||
$p = unserialize(file_get_contents($prefs_file));
|
||||
|
||||
$bin_mediainfo = __DIR__."/bin/mediainfo";
|
||||
$bin_exiftool = __DIR__."/bin/exiftool";
|
||||
$bin_ffmpeg = __DIR__."/bin/ffmpeg";
|
||||
$bin_qlthumb = __DIR__."/bin/ql-thumbnail";
|
||||
$bin_qltool = __DIR__."/bin/qltool";
|
||||
$bin_magick = __DIR__."/bin/magick";
|
||||
$bin_sox = __DIR__."/bin/sox";
|
||||
|
||||
$mode = $argv[1];
|
||||
$fid = $argv[2];
|
||||
$pathname = $argv[3];
|
||||
$bpath = $argv[4];
|
||||
$mytime = $argv[5];
|
||||
|
||||
$tfile = "/tmp/Yuba/".$mytime."/".$fid.".png";
|
||||
|
||||
$shellpath = escapeshellarg($pathname);
|
||||
|
||||
$dbp = new PDO("sqlite:".$bpath."/pool.sqlite3");
|
||||
$dbp->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
$dbp->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
|
||||
|
||||
if (@!$dbp->query("SELECT EXISTS(SELECT 1 FROM icons WHERE fid='".$fid."')")->fetch()[0]) {
|
||||
|
||||
$stmt = $dbp->prepare("INSERT INTO icons VALUES (:fid, :hash, :created, :relative_path, :tool)");
|
||||
|
||||
$cmd = $bin_qltool." di ".$shellpath." ".$p['thumb_size']." ".$p['thumb_size']." | base64 --decode | ".$bin_magick." convert - -scale 50% -strip -define png:compression-level=9 ".$tfile;
|
||||
shell_exec($cmd);
|
||||
|
||||
$stmt->BindValue(":fid",$fid);
|
||||
if (@filesize($tfile)) {
|
||||
$hash = md5_file($tfile);
|
||||
$stmt->BindValue(":hash",$hash);
|
||||
if ($row = @$dbp->query("SELECT * FROM icons WHERE hash='".$hash."'")->fetchAll()[0]) {
|
||||
$stmt->BindValue(":created",$row['created']);
|
||||
$stmt->BindValue(":relative_path",$row['relative_path']);
|
||||
$stmt->BindValue(":tool",$row['tool']);
|
||||
} else {
|
||||
$dfile = $bpath."/icons/".substr($hash, 0, 2)."/".$hash.".png";
|
||||
if (!is_dir(dirname($dfile))) { mkdir(dirname($dfile)); }
|
||||
rename($tfile,$dfile);
|
||||
$stmt->BindValue(":created",time());
|
||||
$stmt->BindValue(":relative_path",substr($dfile,strlen($bpath)));
|
||||
$stmt->BindValue(":tool","qltool");
|
||||
}
|
||||
}
|
||||
$stmt->execute();
|
||||
|
||||
}
|
||||
|
||||
$stmt = $dbp->prepare("UPDATE counter SET count = count + 1 WHERE time='".$mytime."'");
|
||||
$stmt->execute();
|
||||
echo "\nPROGRESS: ".$dbp->query("SELECT count FROM counter WHERE time='".$mytime."'")->fetch()['count'];
|
||||
|
||||
?>
|
||||
@@ -4,8 +4,16 @@
|
||||
// Polyfill
|
||||
// Fill a volume with many small files
|
||||
|
||||
$dmg = "/Users/".get_current_user()."/Desktop/Polyfill.sparsebundle";
|
||||
if (file_exists($dmg)) {
|
||||
exec("trash ".$dmg."; umount -f /Volumes/Polyfill");
|
||||
}
|
||||
exec("hdiutil create -size 5g -fs HFS+ -type SPARSEBUNDLE -volname Polyfill -attach ".$dmg);
|
||||
|
||||
$base = "/Volumes/Polyfill";
|
||||
$total = 10000;
|
||||
//$total = 10000;
|
||||
$total = 2000;
|
||||
$sample_files = glob("sample_files/*.*");
|
||||
|
||||
for ($i = 0; $i < $total; $i++) {
|
||||
|
||||
@@ -35,8 +43,13 @@ for ($i = 0; $i < $total; $i++) {
|
||||
}
|
||||
|
||||
echo $dest."\n";
|
||||
copy("test.jpg",$dest.".jpg");
|
||||
|
||||
$use = $sample_files[rand(0,count($sample_files))];
|
||||
$ext = pathinfo($use, PATHINFO_EXTENSION);
|
||||
copy($use,$dest.".".$ext);
|
||||
//file_put_contents($dest,serialize($levels));
|
||||
}
|
||||
|
||||
exec("open /Volumes/Polyfill");
|
||||
|
||||
?>
|
||||
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 5.9 KiB After Width: | Height: | Size: 5.9 KiB |
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 3.1 KiB |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 9.8 KiB After Width: | Height: | Size: 9.8 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
BIN
utils/sample_files/large.mp4
Normal file
BIN
utils/sample_files/mlk.flac
Normal file
|
Before Width: | Height: | Size: 44 KiB After Width: | Height: | Size: 44 KiB |
|
Before Width: | Height: | Size: 7.7 KiB After Width: | Height: | Size: 7.7 KiB |
|
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 36 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 36 KiB |
|
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 30 KiB |
6256
utils/sample_files/test.ai
Normal file
BIN
utils/sample_files/test.jpg
Normal file
|
After Width: | Height: | Size: 370 KiB |
BIN
utils/sample_files/test.psd
Normal file
22
utils/sample_files/test.svg
Normal file
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 22.0.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
viewBox="0 0 612 792" style="enable-background:new 0 0 612 792;" xml:space="preserve">
|
||||
<style type="text/css">
|
||||
.st0{fill:url(#SVGID_1_);}
|
||||
.st1{fill:none;stroke:#000000;stroke-width:20;stroke-linecap:round;stroke-miterlimit:10;}
|
||||
.st2{fill:#8D5CA6;}
|
||||
</style>
|
||||
<linearGradient id="SVGID_1_" gradientUnits="userSpaceOnUse" x1="148.1566" y1="562.8434" x2="627.6747" y2="562.8434">
|
||||
<stop offset="0" style="stop-color:#F69380"/>
|
||||
<stop offset="1" style="stop-color:#00B798"/>
|
||||
</linearGradient>
|
||||
<rect x="148.2" y="396.3" class="st0" width="479.5" height="333.1"/>
|
||||
<path class="st1" d="M541.2,492.1c-57.9,107.8-192.2,148.3-300,90.4c-86.2-46.3-118.6-153.8-72.3-240c37-69,123-94.9,192-57.8
|
||||
c55.2,29.6,75.9,98.4,46.3,153.6c-23.7,44.2-78.7,60.7-122.9,37c-35.3-19-48.6-63-29.6-98.3c15.2-28.3,50.4-38.9,78.6-23.7
|
||||
c22.6,12.1,31.1,40.3,19,62.9c-9.7,18.1-32.2,24.9-50.3,15.2c-14.5-7.8-19.9-25.8-12.1-40.3c6.2-11.6,20.6-15.9,32.2-9.7
|
||||
c9.3,5,12.7,16.5,7.8,25.8c-4,7.4-13.2,10.2-20.6,6.2c-5.9-3.2-8.2-10.6-5-16.5c2.5-4.7,8.5-6.5,13.2-4c3.8,2,5.2,6.8,3.2,10.6
|
||||
c-1.6,3-5.4,4.2-8.4,2.5c-2.4-1.3-3.3-4.3-2-6.8c1-1.9,3.5-2.7,5.4-1.6c1.6,0.8,2.1,2.8,1.3,4.3"/>
|
||||
<polygon class="st2" points="12,147.5 -18,34.5 89.9,79.4 188,16 178.7,132.5 269.3,206.2 155.7,233.3 113.6,342.3 52.7,242.6
|
||||
-64,236.2 "/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.5 KiB |
29
web/rtc.php
@@ -15,7 +15,7 @@ ref::config('validHtml', TRUE);
|
||||
$db_dir = "data/skim";
|
||||
$icon_size = 96;
|
||||
$pad = 40;
|
||||
$overlay_exts = array("txt","php","inc","sh","md","json","cmd");
|
||||
$border_tools = array("sips","sox","ffmpeg","ql-thumbnail");
|
||||
|
||||
?>
|
||||
|
||||
@@ -91,14 +91,18 @@ img.tiny { vertical-align: middle; width: 18px; height: 18px; margin: 0px 4px 0p
|
||||
|
||||
div.size { color: grey; margin-top: 3px; }
|
||||
|
||||
img#thumb { padding: 6px; border: 1px solid gainsboro; }
|
||||
img#thumb { padding: 6px;
|
||||
outline: 1px solid gainsboro;
|
||||
outline-offset: -7px;
|
||||
border: 1px solid gainsboro;
|
||||
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
img#item { float: left; margin-right: 10px; width: 32px; height: 32px; }
|
||||
img { margin-bottom: 8px; }
|
||||
img#thumb.overlay { border: 0px !important;
|
||||
padding: 6px !important;
|
||||
-webkit-mask-image: url('/icons/mask.png');
|
||||
-webkit-mask-size: 100%;
|
||||
outline: 1px solid black; }
|
||||
|
||||
div.title { padding: 0px 10px 0px 10px; }
|
||||
|
||||
div.fileinfo { font-size: 12px; }
|
||||
div.fileinfo span.title { display: table-cell; font-weight: bold; width: 200px; }
|
||||
div.fileinfo span.value { display: table-cell; }
|
||||
@@ -503,7 +507,7 @@ if ($db_file) {
|
||||
$height = $row_a['thumb_height'];
|
||||
$realfile = dirname($db_file).$row_a['thumb_filename'];
|
||||
if (array_key_exists("thumb_tool",$row_a)) {
|
||||
if ($row_a['thumb_tool'] != "qltool" && $row_a['thumb_tool'] != "qlmanage") {
|
||||
if (in_array($row_a['thumb_tool'], $border_tools)) {
|
||||
// put a border around images that are not icons
|
||||
$border = "id='thumb'";
|
||||
} else {
|
||||
@@ -660,13 +664,6 @@ if ($db_file) {
|
||||
$visibility = "unhidden";
|
||||
}
|
||||
|
||||
//if (in_array($item['Extension'],$overlay_exts) && $item['thumb_filename']) {
|
||||
//
|
||||
//$realfile = dirname($db_file).$item['thumb_filename'];
|
||||
//$icon = "<img id='thumb' class='overlay' src='".$realfile."' width='".($icon_size*.8)."' height='".$icon_size."' data-width='".($icon_size*.8)."' data-height='".$icon_size."'>";
|
||||
|
||||
//} elseif ($item['thumb_filename']) {
|
||||
|
||||
if ($item['thumb_filename']) {
|
||||
$aspect = $item['thumb_width']/$item['thumb_height'];
|
||||
if ($aspect > 1) {
|
||||
@@ -682,7 +679,7 @@ if ($db_file) {
|
||||
}
|
||||
$realfile = dirname($db_file).$item['thumb_filename'];
|
||||
if (array_key_exists("thumb_tool",$item)) {
|
||||
if ($row_a['thumb_tool'] != "qltool" && $row_a['thumb_tool'] != "qlmanage" && $item['Type'] != "dir") {
|
||||
if (in_array($item['thumb_tool'], $border_tools) && $item['Type'] != "dir") {
|
||||
// put a border around images that are not icons
|
||||
$border = "id='thumb'";
|
||||
} else {
|
||||
|
||||