Switched from ufraw to darktable as ufraw is no longer in Ubuntu
Signed-off-by: James Ketrenos <james_gitlab@ketrenos.com>
This commit is contained in:
parent
6f51d5dc4d
commit
44b157ee8b
@ -13,8 +13,8 @@ RUN DEBIAN_FRONTEND=NONINTERACTIVE apt-get install -y \
|
||||
make \
|
||||
cmake
|
||||
|
||||
# You can then install the latest npm, polymer-cli, and bower:
|
||||
RUN npm install --global npm@latest npx
|
||||
# You can then install the latest npm and npx
|
||||
RUN npm install --global npm@latest
|
||||
|
||||
# Speed up face-recognition and dev tools
|
||||
RUN apt-get install -y libopenblas-dev
|
||||
@ -22,8 +22,8 @@ RUN apt-get install -y libopenblas-dev
|
||||
# Required for dlib to build
|
||||
RUN apt-get install -y libx11-dev libpng16-16
|
||||
|
||||
# NEF processing uses ufraw-batch
|
||||
RUN apt-get install -y ufraw-batch
|
||||
# NEF processing uses darktable-cli, provided via darktable
|
||||
RUN apt-get install -y darktable
|
||||
|
||||
# Create a user with sudo access
|
||||
RUN DEBIAN_FRONTEND=noninteractive \
|
||||
|
@ -24,12 +24,8 @@ wget -qO- https://deb.nodesource.com/setup_8.x | sudo bash -
|
||||
sudo apt-get install --yes nodejs
|
||||
```
|
||||
|
||||
You can then install the latest npm, polymer-cli, and bower:
|
||||
|
||||
```bash
|
||||
sudo npm install --global npm@latest
|
||||
sudo npm install --global polymer-cli
|
||||
sudo npm install --global bower
|
||||
```
|
||||
|
||||
# Install BLAS to improve performance, and dev tools so
|
||||
@ -40,9 +36,9 @@ sudo apt install -y libopenblas-dev cmake
|
||||
```
|
||||
|
||||
###
|
||||
NEF processing uses ufraw-batch
|
||||
NEF processing uses darktable
|
||||
```
|
||||
sudo apt install -y ufraw-batch
|
||||
sudo apt install -y darktable
|
||||
```
|
||||
|
||||
### Create `photos` user for DB
|
||||
|
@ -61,8 +61,8 @@ const { spawn } = require('child_process');
|
||||
|
||||
const sharp = require("sharp"), exif = require("exif-reader");
|
||||
|
||||
function convertRawToJpg(path, file) {
|
||||
setStatus("Converting " + path + file);
|
||||
function convertRawToJpg(path, raw, file) {
|
||||
setStatus(`Converting ${path}${raw} to ${file}.`);
|
||||
|
||||
path = picturesPath + path;
|
||||
|
||||
@ -73,30 +73,23 @@ function convertRawToJpg(path, file) {
|
||||
return;
|
||||
}
|
||||
|
||||
const ufraw = spawn("ufraw-batch", [
|
||||
"--silent",
|
||||
"--wb=camera",
|
||||
"--rotate=camera",
|
||||
"--out-type=jpg",
|
||||
"--compression=90",
|
||||
"--exif",
|
||||
"--overwrite",
|
||||
"--output", path + file.replace(rawExtension, ".jpg"),
|
||||
const darktable = spawn("darktable-cli", [
|
||||
path + raw,
|
||||
path + file
|
||||
]);
|
||||
|
||||
const stderr = [];
|
||||
ufraw.stderr.on('data', function(data) {
|
||||
darktable.stderr.on('data', function(data) {
|
||||
stderr.push(data);
|
||||
});
|
||||
|
||||
return new Promise(function(ufraw, resolve, reject) {
|
||||
ufraw.on('exit', function(stderr, code, signal) {
|
||||
return new Promise((resolve, reject) => {
|
||||
darktable.on('exit', (code, signal) => {
|
||||
if (signal || code != 0) {
|
||||
let error = "UFRAW for " + path + file + " returned an error: " + code + "\n" + signal + "\n" + stderr.join("\n") + "\n";
|
||||
let error = "darktable for " + path + file + " returned an error: " + code + "\n" + signal + "\n" + stderr.join("\n") + "\n";
|
||||
setStatus(error, "error");
|
||||
return moveCorrupt(path, file).then(function() {
|
||||
setStatus("ufraw failed", "warn");
|
||||
setStatus("darktable failed", "warn");
|
||||
return reject(error);
|
||||
}).catch(function(error) {
|
||||
setStatus("moveCorrupt failed", "warn");
|
||||
@ -104,9 +97,9 @@ function convertRawToJpg(path, file) {
|
||||
});
|
||||
}
|
||||
return mkdir(path + "raw").then(function() {
|
||||
fs.rename(path + file, path + "raw/" + file, function(err) {
|
||||
fs.rename(path + raw, path + "raw/" + raw, function(err) {
|
||||
if (err) {
|
||||
setStatus("Unable to move RAW file: " + path + file, "error");
|
||||
setStatus("Unable to move RAW file: " + path + raw, "error");
|
||||
return reject(err);
|
||||
}
|
||||
return resolve();
|
||||
@ -115,8 +108,8 @@ function convertRawToJpg(path, file) {
|
||||
setStatus("mkdir failed", "warn");
|
||||
return reject(error);
|
||||
});
|
||||
}.bind(this, ufraw));
|
||||
}.bind(this, stderr));
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
@ -164,7 +157,26 @@ function processBlock(items) {
|
||||
|
||||
let toProcess = processing.length, lastMessage = moment();
|
||||
setStatus("Items to be processed: " + toProcess);
|
||||
return Promise.mapSeries(processing, function(asset) {
|
||||
return Promise.mapSeries(processing, (asset) => {
|
||||
if (!asset.raw) {
|
||||
return;
|
||||
}
|
||||
|
||||
const path = asset.album.path;
|
||||
|
||||
return exists(picturesPath + path + asset.filename).then(function(exist) {
|
||||
if (exist) {
|
||||
return asset;
|
||||
}
|
||||
|
||||
return mkdir(picturesPath + path + "raw").then(function() {
|
||||
return convertRawToJpg(path, asset.raw, asset.filename);
|
||||
}).then(function() {
|
||||
console.log("Done converting...");
|
||||
});
|
||||
});
|
||||
}).then(() => {
|
||||
return Promise.mapSeries(processing, (asset) => {
|
||||
return computeHash(picturesPath + asset.album.path + asset.filename).then(function(hash) {
|
||||
asset.hash = hash;
|
||||
return asset;
|
||||
@ -217,23 +229,6 @@ function processBlock(items) {
|
||||
created = asset.stats.mtime,
|
||||
albumId = asset.album.id;
|
||||
|
||||
let tmp = Promise.resolve(file);
|
||||
/* If this is a Nikon RAW file, convert it to JPG and move to /raw dir */
|
||||
if (rawExtension.exec(file)) {
|
||||
tmp = exists(picturesPath + path + file.replace(rawExtension, ".jpg")).then(function(exist) {
|
||||
if (exist) {
|
||||
return file.replace(rawExtension, ".jpg"); /* We converted from NEF/ORF => JPG */
|
||||
}
|
||||
|
||||
return mkdir(picturesPath + path + "raw").then(function() {
|
||||
return convertRawToJpg(path, file);
|
||||
}).then(function() {
|
||||
return file.replace(rawExtension, ".jpg"); /* We converted from NEF/ORF => JPG */
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
return tmp.then(function(file) {
|
||||
var src = picturesPath + path + file,
|
||||
image = sharp(src);
|
||||
|
||||
@ -321,31 +316,7 @@ function processBlock(items) {
|
||||
});
|
||||
}).catch(function(error) {
|
||||
setStatus("Error reading image " + src + ":\n" + error, "error");
|
||||
return moveCorrupt(path, file).then(function() {
|
||||
|
||||
/* If the original file was not a NEF/ORF, we are done... */
|
||||
if (!rawExtension.exec(asset.filename)) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* ... otherwise, attempt to re-convert the NEF/ORF->JPG and then resize again */
|
||||
for (var i = 0; i < triedClean.length; i++) {
|
||||
if (triedClean[i] == path + file) {
|
||||
/* Move the NEF/ORF to /corrupt as well so it isn't re-checked again and again... */
|
||||
// return moveCorrupt(path, asset.filename);
|
||||
|
||||
setStatus("Already attempted to convert NEF/ORF to JPG: " + path + file, "error");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
setStatus("Adding " + path + file + " back onto processing queue.", "error");
|
||||
triedClean.push(path + file);
|
||||
processBlock([ path, file, created, albumId ]);
|
||||
});
|
||||
});
|
||||
}).catch(function() {
|
||||
setStatus("Continuing file processing.", "warn");
|
||||
return moveCorrupt(path, file);
|
||||
});
|
||||
}).then(function() {
|
||||
toProcess--;
|
||||
@ -354,6 +325,7 @@ function processBlock(items) {
|
||||
lastMessage = moment();
|
||||
}
|
||||
});
|
||||
});
|
||||
}).catch(function(error) {
|
||||
setStatus("Error processing file. Continuing.", "error");
|
||||
throw error;
|
||||
@ -469,8 +441,8 @@ function scanDir(parent, path) {
|
||||
|
||||
album.hasAssets = true;
|
||||
|
||||
assets.push({
|
||||
filename: file.replace(rawExtension, ".jpg"), /* We will be converting from NEF/ORF => JPG */
|
||||
const asset = {
|
||||
filename: file.replace(rawExtension, ".jpg"),
|
||||
name: file.replace(/.[^.]*$/, ""),
|
||||
stats: {
|
||||
mtime: stats.mtime,
|
||||
@ -478,7 +450,11 @@ function scanDir(parent, path) {
|
||||
},
|
||||
size: stats.size,
|
||||
album: album
|
||||
});
|
||||
}
|
||||
if (file != asset.filename) {
|
||||
asset.raw = file;
|
||||
}
|
||||
assets.push(asset);
|
||||
});
|
||||
});
|
||||
}).then(function() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user