Introduction
The unix-toolbox.js is a port of many popular Unix command line tools to Javascript using Mozilla's emscripten project. It runs completely on the client-side and requires WebWorker support in the client's browser.
Currently Supported Commands
-
GnuPG
-
gpgOpenPGP encryption and signing tool
-
-
ImageMagick
-
compositeoverlaps one image over another. -
conjureinterprets and executes scripts written in the Magick Scripting Language (MSL). -
convertconvert between image formats as well as resize an image, blur, crop, despeckle, dither, draw on, flip, join, re-sample, and much more. -
identifydescribes the format and characteristics of one or more image files. -
mogrifyresize an image, blur, crop, despeckle, dither, draw on, flip, join, re-sample, and much more. Mogrify overwrites the original image file, whereas, convert(1) writes to a different image file. -
montagecreate a composite image by combining several separate images. The images are tiled on the composite image optionally adorned with a border, frame, image name, and more. -
streama lightweight tool to stream one or more pixel components of the image or portion of the image to your choice of storage formats.
-
-
Poppler
-
pdfdetachPortable Document Format (PDF) document embedded file extractor -
pdffontsPortable Document Format (PDF) font analyzer -
pdfimagesPortable Document Format (PDF) image extractor -
pdfinfoPortable Document Format (PDF) document information extractor -
pdfseparatePortable Document Format (PDF) page extractor -
pdftohtmlprogram to convert PDF files into HTML, XML and PNG images -
pdftoppmPortable Document Format (PDF) to Portable Pixmap (PPM) converter -
pdftopsPortable Document Format (PDF) to PostScript converter -
pdftotextPortable Document Format (PDF) to text converter
-
-
File
-
filedetermine file type
-
-
XZ Utils
-
xzCompress or decompress .xz files -
xzdecSmall .xz decompressor
-
Example
The Javascript class Interface can be used to initiate a WebWorker and communicate with it..
This is an example from ImageMagick's convert tool that loads some XML files required by ImageMagick and then loads the image test.png, rotates it and converts it to JPEG format:
<script src="toolbox-base/interface.js"></script>
<script>
var convert = new Interface('convert-worker.js');
// print convert output to console
convert.on_stdout = function(txt) { console.log(txt); };
convert.on_stderr = function(txt) { console.log(txt); };
// load ImageMagick's configuration files
convert.mkdir('/', 'usr/local/etc/ImageMagick').then(function() {
convert.addUrl('./src/config/magic.xml', '/usr/local/etc/ImageMagick', 'magic.xml');
convert.addUrl('./src/config/coder.xml', '/usr/local/etc/ImageMagick', 'coder.xml');
convert.addUrl('./src/config/policy.xml', '/usr/local/etc/ImageMagick', 'policy.xml');
convert.addUrl('./src/config/english.xml', '/usr/local/etc/ImageMagick', 'english.xml');
convert.addUrl('./src/config/locale.xml', '/usr/local/etc/ImageMagick', 'locale.xml');
convert.addUrl('./src/config/delegates.xml', '/usr/local/etc/ImageMagick', 'delegates.xml');
// load image to convert
convert.addUrl('demo/test.png', '/', 'test.png');
convert.allDone().then(function() {
convert.run('-rotate', '90', '/test.png', '/test-rotated-90.jpg').then(function() {
convert.getFile('/', 'test-rotated-90.jpg').then(function(contents) {
var img = document.createElement("img");
img.src = "data:image/jpeg;base64,"+window.btoa(contents);
var body = document.getElementsByTagName("body")[0];
body.appendChild(img);
});
});
});
});
</script>