| 1 |
<!-- vim: ft=html |
| 2 |
This is the minimalistic GUI wrapper for minidjvu. |
| 3 |
.hta extension allows it to run under Windows as an application. |
| 4 |
--> |
| 5 |
|
| 6 |
<HTML><HEAD><TITLE>TIFF to DjVu (minidjvu 0.8)</TITLE> |
| 7 |
<SCRIPT> |
| 8 |
|
| 9 |
var shell = new ActiveXObject("WScript.Shell"); |
| 10 |
var fs = new ActiveXObject("Scripting.FileSystemObject"); |
| 11 |
|
| 12 |
// Return the index of last / or \ char |
| 13 |
function lastSeparator(s) |
| 14 |
{ |
| 15 |
var i = s.lastIndexOf("\\", s.length); |
| 16 |
var j = s.lastIndexOf("/", s.length); |
| 17 |
if (i > j) |
| 18 |
return i; |
| 19 |
else |
| 20 |
return j; |
| 21 |
} |
| 22 |
|
| 23 |
|
| 24 |
// a\b\c -> a\b |
| 25 |
function getDir(s) |
| 26 |
{ |
| 27 |
var i = lastSeparator(s); |
| 28 |
if (i == -1) |
| 29 |
return "."; |
| 30 |
else |
| 31 |
return s.substring(0, i); |
| 32 |
} |
| 33 |
|
| 34 |
|
| 35 |
// a\b\c -> c |
| 36 |
function getName(s) |
| 37 |
{ |
| 38 |
return s.substr(lastSeparator(s) + 1); |
| 39 |
} |
| 40 |
|
| 41 |
// a\b\c.ext -> c |
| 42 |
function getBaseName(s) |
| 43 |
{ |
| 44 |
s = getName(s); |
| 45 |
var i = s.lastIndexOf(".", s.length); |
| 46 |
if (i == -1) |
| 47 |
return s; |
| 48 |
else |
| 49 |
return s.substring(0, i); |
| 50 |
} |
| 51 |
|
| 52 |
function getWinDjViewPath() |
| 53 |
{ |
| 54 |
var sPath = ""; |
| 55 |
try { |
| 56 |
sCmd = shell.RegRead ("HKCR\\Applications\\WinDjView.exe\\shell\\open\\command\\"); |
| 57 |
aParts = sCmd.split("\""); |
| 58 |
i = 0; |
| 59 |
while (i < aParts.length && aParts[i] == "") i++; |
| 60 |
sPath = aParts[i]; |
| 61 |
} catch (err) {}; |
| 62 |
return sPath; |
| 63 |
} |
| 64 |
|
| 65 |
function checkViewer() |
| 66 |
{ |
| 67 |
sPath = getWinDjViewPath(); |
| 68 |
view.disabled = (sPath == ""); |
| 69 |
viewpath.value = sPath; |
| 70 |
} |
| 71 |
|
| 72 |
function getOutputPath(ourDir) |
| 73 |
{ |
| 74 |
var sOut; |
| 75 |
|
| 76 |
// Decide what output file is |
| 77 |
if (specifyOutput.checked) |
| 78 |
sOut = ourDir + "\\" + outputfile.value; |
| 79 |
else |
| 80 |
sOut = ourDir + "\\" + getBaseName(inputfile.value) + ".djvu"; |
| 81 |
|
| 82 |
return sOut; |
| 83 |
} |
| 84 |
|
| 85 |
function update() |
| 86 |
{ |
| 87 |
if (shell && fs) |
| 88 |
run.innerHTML="<BUTTON TYPE=submit onClick=\"onRun()\"><FONT SIZE=+1>Run</FONT></BUTTON>"; |
| 89 |
|
| 90 |
var ourDir = getDir(inputfile.value); |
| 91 |
|
| 92 |
// Decide what input files are |
| 93 |
|
| 94 |
if (wholedir.checked) |
| 95 |
input = ourDir + "\\*.tif*"; |
| 96 |
else |
| 97 |
input = inputfile.value; |
| 98 |
|
| 99 |
// minidjvu |
| 100 |
|
| 101 |
options = " --report"; // Useful only in multipage mode, but doesn't harm anyway |
| 102 |
|
| 103 |
if (usedpi.checked) |
| 104 |
options += " --dpi " + dpi.value; |
| 105 |
|
| 106 |
if (usedict.checked) |
| 107 |
options += " --pages-per-dict " + ppd.value; |
| 108 |
|
| 109 |
if (uselossy.checked) |
| 110 |
options += " --lossy --aggression " + aggression.value; |
| 111 |
|
| 112 |
if (indirect.checked) |
| 113 |
options += " --indirect " |
| 114 |
|
| 115 |
mdjvuOutput = getOutputPath(ourDir); |
| 116 |
|
| 117 |
job.value = "minidjvu.exe" + options + " " + input + " " + mdjvuOutput + "\n"; |
| 118 |
} |
| 119 |
|
| 120 |
function onRun() |
| 121 |
{ |
| 122 |
shell.run("cmd.exe /C " + job.value, 1, 1); |
| 123 |
if (view.checked) |
| 124 |
shell.run("\"" + viewpath.value + "\" \"" + getOutputPath(getDir(inputfile.value)) +"\""); |
| 125 |
} |
| 126 |
|
| 127 |
</SCRIPT> |
| 128 |
</HEAD> |
| 129 |
<BODY BGCOLOR="#E0E0E0" onLoad="checkViewer()"><FONT FACE="Arial, Verdana"> |
| 130 |
|
| 131 |
<TABLE CELLPADDING=10 WIDTH=100%> |
| 132 |
<TR><TD> |
| 133 |
<TABLE CELLPADDING=5> |
| 134 |
<TR><TD> |
| 135 |
<FIELDSET><LEGEND>Input</LEGEND> |
| 136 |
<TABLE CELLSPACING=3> |
| 137 |
<TR><TD> |
| 138 |
Pick a file: <INPUT ID=inputfile TYPE=file onChange="update()"> |
| 139 |
<TR><TD> |
| 140 |
<TR><TD> |
| 141 |
<INPUT ID=wholedir type=radio name=inputtype checked onClick="update()"> File from an input directory |
| 142 |
<TR><TD> |
| 143 |
<INPUT ID=singlepage type=radio name=inputtype onClick="update()"> Single image or multipage TIFF |
| 144 |
<TR><TD> |
| 145 |
</TABLE> |
| 146 |
</FIELDSET> |
| 147 |
<TR><TD> |
| 148 |
<FIELDSET> |
| 149 |
<LEGEND>Options</LEGEND> |
| 150 |
<TABLE WIDTH=100%> |
| 151 |
<TR><TD><INPUT ID=specifyOutput type=checkbox onClick="update()"> output djvu |
| 152 |
<TD><INPUT ID=outputfile type=text onChange="specifyOutput.checked = true; update()"> |
| 153 |
<TR><TD><INPUT ID=uselossy type=checkbox checked onClick="update()"> aggression |
| 154 |
<TD><INPUT ID=aggression TYPE=text SIZE=5 VALUE="100" onChange="uselossy.checked = true; update()"> |
| 155 |
<TR><TD><INPUT ID=usedict type=checkbox checked onClick="update()"> pages/dict |
| 156 |
<TD><INPUT ID=ppd TYPE=text SIZE=5 VALUE="5" onChange="usedict.checked = true; update()"> |
| 157 |
<TR><TD><INPUT ID=usedpi type=checkbox onClick="update()"> resolution |
| 158 |
<TD><INPUT ID=dpi TYPE=text SIZE=5 VALUE="300" onChange="usedpi.checked = true; update()"> |
| 159 |
<TR><TD COLSPAN=2><INPUT ID=indirect type=checkbox onClick="update()"> output DjVu indirect |
| 160 |
<TR><TD COLSPAN=2><INPUT ID=view type=checkbox> view result with WinDjView |
| 161 |
<TR><TD COLSPAN=2><INPUT ID=viewpath TYPE=hidden> |
| 162 |
</TABLE> |
| 163 |
</FIELDSET> |
| 164 |
</TABLE> |
| 165 |
<TD> |
| 166 |
<FONT SIZE=+1><a href="doc/tifftodjvu_help.html">Help</a></FONT> |
| 167 |
<P> |
| 168 |
Preview of the command line to run: |
| 169 |
<P> |
| 170 |
<TEXTAREA ID=job rows=11 cols=40 readonly></TEXTAREA> |
| 171 |
<P> |
| 172 |
<DIV ID=run></DIV> |
| 173 |
</TABLE> |
| 174 |
</HTML> |