I'm trying to convert my photo workflow to nodejs. From every jpg that Lightroom spits out, I want to make: 1) a 200x200 px thumbnail without watermark 2) a highly compressed jpg, same pixel size as the src, but with a watermark overlaid
I have the task of creating the thumbnail done:
gm(photo.photoPath)
.size(function (error, size) {
// I need to know the pixel size of the photo first!
if (error) {
console.log(error);
} else {
// Succesfully loaded
photo.size = size;
photo.orientation = size.height > size.width ? 'portrait' : 'landscape';
var cropSize = size.height < size.width ? size.height : size.width;
var left = size.height > size.width ? 0 : Math.round((size.width - size.height) / 2);
.crop(cropSize, cropSize, left, 0)
.resize(200, 200)
.unsharp(1, 1, 1.2, 0.05)
.noProfile()
.quality(30)
.write(photo.thumbFile, function (err) {
if (!err) {
console.log('Thumb aangemaakt als /tn/' + photo.cryptedName);
} else {
console.log('Problem saving: ' + err);
}
});
}
});
So essentially this is what I want my workflow to do:
src file from Lightroom
|
|
open file with GM
/ \
/ \
Overlay watermark resize 200x200px
(transparent png) |
| |
| sharpen lightly
| |
| |
| |
save as /lowquality/xxxx.jpg save as /thumb/xxxx.jpg
And I'm stuck at the point where I need to create the two separate versions, right after opening. Please help!