implements querystring transformation #928
802
package-lock.json
generated
|
@ -46,6 +46,7 @@
|
||||||
"express-http-context": "^1.2.0",
|
"express-http-context": "^1.2.0",
|
||||||
"generate-password": "^1.4.1",
|
"generate-password": "^1.4.1",
|
||||||
"get-video-dimensions": "^1.0.0",
|
"get-video-dimensions": "^1.0.0",
|
||||||
|
"gm": "^1.23.1",
|
||||||
"helmet": "^3.15.0",
|
"helmet": "^3.15.0",
|
||||||
"image-size": "^0.6.3",
|
"image-size": "^0.6.3",
|
||||||
"inquirer": "^5.2.0",
|
"inquirer": "^5.2.0",
|
||||||
|
|
|
@ -15,9 +15,20 @@ const BLOCKED_CLAIM = 'BLOCKED_CLAIM';
|
||||||
const NO_FILE = 'NO_FILE';
|
const NO_FILE = 'NO_FILE';
|
||||||
const CONTENT_UNAVAILABLE = 'CONTENT_UNAVAILABLE';
|
const CONTENT_UNAVAILABLE = 'CONTENT_UNAVAILABLE';
|
||||||
|
|
||||||
const { publishing: { serveOnlyApproved, approvedChannels } } = require('@config/siteConfig');
|
const {
|
||||||
|
publishing: { serveOnlyApproved, approvedChannels },
|
||||||
|
} = require('@config/siteConfig');
|
||||||
|
|
||||||
const getClaimIdAndServeAsset = (channelName, channelClaimId, claimName, claimId, originalUrl, ip, res, headers) => {
|
const getClaimIdAndServeAsset = (
|
||||||
|
channelName,
|
||||||
|
channelClaimId,
|
||||||
|
claimName,
|
||||||
|
claimId,
|
||||||
|
originalUrl,
|
||||||
|
ip,
|
||||||
|
res,
|
||||||
|
headers
|
||||||
|
) => {
|
||||||
getClaimId(channelName, channelClaimId, claimName, claimId)
|
getClaimId(channelName, channelClaimId, claimName, claimId)
|
||||||
.then(fullClaimId => {
|
.then(fullClaimId => {
|
||||||
claimId = fullClaimId;
|
claimId = fullClaimId;
|
||||||
|
@ -39,11 +50,19 @@ const getClaimIdAndServeAsset = (channelName, channelClaimId, claimName, claimId
|
||||||
.then(claim => {
|
.then(claim => {
|
||||||
let claimDataValues = claim.dataValues;
|
let claimDataValues = claim.dataValues;
|
||||||
|
|
||||||
if (serveOnlyApproved && !isApprovedChannel({ longId: claimDataValues.publisher_id || claimDataValues.certificateId }, approvedChannels)) {
|
if (
|
||||||
|
serveOnlyApproved &&
|
||||||
|
!isApprovedChannel(
|
||||||
|
{ longId: claimDataValues.publisher_id || claimDataValues.certificateId },
|
||||||
|
approvedChannels
|
||||||
|
)
|
||||||
|
) {
|
||||||
throw new Error(CONTENT_UNAVAILABLE);
|
throw new Error(CONTENT_UNAVAILABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
let outpoint = claimDataValues.outpoint || `${claimDataValues.transaction_hash_id}:${claimDataValues.vout}`;
|
let outpoint =
|
||||||
|
claimDataValues.outpoint ||
|
||||||
|
`${claimDataValues.transaction_hash_id}:${claimDataValues.vout}`;
|
||||||
logger.debug('Outpoint:', outpoint);
|
logger.debug('Outpoint:', outpoint);
|
||||||
return db.Blocked.isNotBlocked(outpoint).then(() => {
|
return db.Blocked.isNotBlocked(outpoint).then(() => {
|
||||||
// If content was found, is approved, and not blocked - log a view.
|
// If content was found, is approved, and not blocked - log a view.
|
||||||
|
@ -70,7 +89,7 @@ const getClaimIdAndServeAsset = (channelName, channelClaimId, claimName, claimId
|
||||||
if (!fileRecord) {
|
if (!fileRecord) {
|
||||||
throw NO_FILE;
|
throw NO_FILE;
|
||||||
}
|
}
|
||||||
serveFile(fileRecord.dataValues, res);
|
serveFile(fileRecord.dataValues, res, originalUrl);
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
if (error === NO_CLAIM) {
|
if (error === NO_CLAIM) {
|
||||||
|
@ -98,7 +117,8 @@ const getClaimIdAndServeAsset = (channelName, channelClaimId, claimName, claimId
|
||||||
logger.debug('claim was blocked');
|
logger.debug('claim was blocked');
|
||||||
return res.status(451).json({
|
return res.status(451).json({
|
||||||
success: false,
|
success: false,
|
||||||
message: 'In response to a complaint we received under the US Digital Millennium Copyright Act, we have blocked access to this content from our applications. For more details, see https://lbry.io/faq/dmca',
|
message:
|
||||||
|
'In response to a complaint we received under the US Digital Millennium Copyright Act, we have blocked access to this content from our applications. For more details, see https://lbry.io/faq/dmca',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (error === NO_FILE) {
|
if (error === NO_FILE) {
|
||||||
|
|
|
@ -1,9 +1,28 @@
|
||||||
const logger = require('winston');
|
const logger = require('winston');
|
||||||
|
const transformImage = require('./transformImage');
|
||||||
|
const serveFile = async ({ filePath, fileType }, res, originalUrl) => {
|
||||||
|
const queryObject = {};
|
||||||
|
// TODO: replace quick/dirty try catch with better practice
|
||||||
|
try {
|
||||||
|
originalUrl
|
||||||
|
.split('?')[1]
|
||||||
|
.split('&')
|
||||||
|
.map(pair => {
|
||||||
|
if (pair.includes('=')) {
|
||||||
|
let parr = pair.split('=');
|
||||||
|
queryObject[parr[0]] = parr[1];
|
||||||
|
} else queryObject[pair] = true;
|
||||||
|
});
|
||||||
|
} catch (e) {}
|
||||||
|
|
||||||
const serveFile = ({ filePath, fileType }, res) => {
|
|
||||||
if (!fileType) {
|
if (!fileType) {
|
||||||
logger.error(`no fileType provided for ${filePath}`);
|
logger.error(`no fileType provided for ${filePath}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let mediaType = fileType ? fileType.substr(0, fileType.indexOf('/')) : '';
|
||||||
|
const transform =
|
||||||
|
mediaType === 'image' && queryObject.hasOwnProperty('h') && queryObject.hasOwnProperty('w');
|
||||||
|
|
||||||
|
|||||||
const sendFileOptions = {
|
const sendFileOptions = {
|
||||||
headers: {
|
headers: {
|
||||||
'X-Content-Type-Options': 'nosniff',
|
'X-Content-Type-Options': 'nosniff',
|
||||||
|
@ -13,7 +32,15 @@ const serveFile = ({ filePath, fileType }, res) => {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
logger.debug(`fileOptions for ${filePath}:`, sendFileOptions);
|
logger.debug(`fileOptions for ${filePath}:`, sendFileOptions);
|
||||||
|
if (transform) {
|
||||||
|
logger.debug(`transforming and sending file`);
|
||||||
|
|
||||||
|
let xformed = await transformImage(filePath, queryObject);
|
||||||
|
res.status(200).set(sendFileOptions.headers);
|
||||||
|
res.end(xformed, 'binary');
|
||||||
|
} else {
|
||||||
res.status(200).sendFile(filePath, sendFileOptions);
|
res.status(200).sendFile(filePath, sendFileOptions);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = serveFile;
|
module.exports = serveFile;
|
||||||
|
|
76
server/controllers/assets/utils/transformImage.js
Normal file
|
@ -0,0 +1,76 @@
|
||||||
Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/ Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/
Can use Can use `await`
I agree, but that's enough time spent on this feature for now. I agree, but that's enough time spent on this feature for now.
Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/ Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/
Can use Can use `await`
I agree, but that's enough time spent on this feature for now. I agree, but that's enough time spent on this feature for now.
|
|||||||
|
const gm = require('gm');
|
||||||
Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/ Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/
Can use Can use `await`
I agree, but that's enough time spent on this feature for now. I agree, but that's enough time spent on this feature for now.
|
|||||||
|
const logger = require('winston');
|
||||||
Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/ Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/
Can use Can use `await`
I agree, but that's enough time spent on this feature for now. I agree, but that's enough time spent on this feature for now.
|
|||||||
|
const imageMagick = gm.subClass({ imageMagick: true });
|
||||||
Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/ Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/
Can use Can use `await`
I agree, but that's enough time spent on this feature for now. I agree, but that's enough time spent on this feature for now.
|
|||||||
|
const { getImageHeightAndWidth } = require('../../../utils/imageProcessing');
|
||||||
Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/ Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/
Can use Can use `await`
I agree, but that's enough time spent on this feature for now. I agree, but that's enough time spent on this feature for now.
|
|||||||
|
|
||||||
Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/ Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/
Can use Can use `await`
I agree, but that's enough time spent on this feature for now. I agree, but that's enough time spent on this feature for now.
|
|||||||
|
module.exports = function transformImage(path, queryObj) {
|
||||||
Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/ Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/
Can use Can use `await`
I agree, but that's enough time spent on this feature for now. I agree, but that's enough time spent on this feature for now.
|
|||||||
|
return new Promise((resolve, reject) => {
|
||||||
Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/ Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/
Can use Can use `await`
I agree, but that's enough time spent on this feature for now. I agree, but that's enough time spent on this feature for now.
|
|||||||
|
let { h: cHeight = null } = queryObj;
|
||||||
Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/ Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/
Can use Can use `await`
I agree, but that's enough time spent on this feature for now. I agree, but that's enough time spent on this feature for now.
|
|||||||
|
let { w: cWidth = null } = queryObj;
|
||||||
Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/ Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/
Can use Can use `await`
I agree, but that's enough time spent on this feature for now. I agree, but that's enough time spent on this feature for now.
|
|||||||
|
let { t: transform = null } = queryObj;
|
||||||
Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/ Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/
Can use Can use `await`
I agree, but that's enough time spent on this feature for now. I agree, but that's enough time spent on this feature for now.
|
|||||||
|
let { x: xOrigin = null } = queryObj;
|
||||||
Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/ Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/
Can use Can use `await`
I agree, but that's enough time spent on this feature for now. I agree, but that's enough time spent on this feature for now.
|
|||||||
|
let { y: yOrigin = null } = queryObj;
|
||||||
Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/ Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/
Can use Can use `await`
I agree, but that's enough time spent on this feature for now. I agree, but that's enough time spent on this feature for now.
|
|||||||
|
let oHeight,
|
||||||
Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/ Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/
Can use Can use `await`
I agree, but that's enough time spent on this feature for now. I agree, but that's enough time spent on this feature for now.
|
|||||||
|
oWidth = null;
|
||||||
Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/ Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/
Can use Can use `await`
I agree, but that's enough time spent on this feature for now. I agree, but that's enough time spent on this feature for now.
|
|||||||
|
try {
|
||||||
Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/ Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/
Can use Can use `await`
I agree, but that's enough time spent on this feature for now. I agree, but that's enough time spent on this feature for now.
|
|||||||
|
getImageHeightAndWidth(path).then(hwarr => {
|
||||||
Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/ Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/
Can use Can use `await`
I agree, but that's enough time spent on this feature for now. I agree, but that's enough time spent on this feature for now.
|
|||||||
|
oHeight = hwarr[0];
|
||||||
Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/ Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/
Can use Can use `await`
I agree, but that's enough time spent on this feature for now. I agree, but that's enough time spent on this feature for now.
|
|||||||
|
oWidth = hwarr[1];
|
||||||
Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/ Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/
Can use Can use `await`
I agree, but that's enough time spent on this feature for now. I agree, but that's enough time spent on this feature for now.
|
|||||||
|
// conditional logic here
|
||||||
Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/ Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/
Can use Can use `await`
I agree, but that's enough time spent on this feature for now. I agree, but that's enough time spent on this feature for now.
|
|||||||
|
if (transform === 'crop') {
|
||||||
Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/ Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/
Can use Can use `await`
I agree, but that's enough time spent on this feature for now. I agree, but that's enough time spent on this feature for now.
|
|||||||
|
resolve(_cropCenter(path, cWidth, cHeight, oWidth, oHeight));
|
||||||
Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/ Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/
Can use Can use `await`
I agree, but that's enough time spent on this feature for now. I agree, but that's enough time spent on this feature for now.
|
|||||||
|
} else if (transform === 'stretch') {
|
||||||
Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/ Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/
Can use Can use `await`
I agree, but that's enough time spent on this feature for now. I agree, but that's enough time spent on this feature for now.
|
|||||||
|
imageMagick(path)
|
||||||
Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/ Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/
Can use Can use `await`
I agree, but that's enough time spent on this feature for now. I agree, but that's enough time spent on this feature for now.
|
|||||||
|
.resize(cWidth, cHeight, '!')
|
||||||
Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/ Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/
Can use Can use `await`
I agree, but that's enough time spent on this feature for now. I agree, but that's enough time spent on this feature for now.
|
|||||||
|
.toBuffer(null, (err, buf) => {
|
||||||
Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/ Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/
Can use Can use `await`
I agree, but that's enough time spent on this feature for now. I agree, but that's enough time spent on this feature for now.
|
|||||||
|
resolve(buf);
|
||||||
Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/ Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/
Can use Can use `await`
I agree, but that's enough time spent on this feature for now. I agree, but that's enough time spent on this feature for now.
|
|||||||
|
});
|
||||||
Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/ Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/
Can use Can use `await`
I agree, but that's enough time spent on this feature for now. I agree, but that's enough time spent on this feature for now.
|
|||||||
|
} else {
|
||||||
Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/ Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/
Can use Can use `await`
I agree, but that's enough time spent on this feature for now. I agree, but that's enough time spent on this feature for now.
|
|||||||
|
// resize scaled
|
||||||
Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/ Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/
Can use Can use `await`
I agree, but that's enough time spent on this feature for now. I agree, but that's enough time spent on this feature for now.
|
|||||||
|
imageMagick(path)
|
||||||
Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/ Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/
Can use Can use `await`
I agree, but that's enough time spent on this feature for now. I agree, but that's enough time spent on this feature for now.
|
|||||||
|
.resize(cWidth, cHeight)
|
||||||
Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/ Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/
Can use Can use `await`
I agree, but that's enough time spent on this feature for now. I agree, but that's enough time spent on this feature for now.
|
|||||||
|
.toBuffer(null, (err, buf) => {
|
||||||
Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/ Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/
Can use Can use `await`
I agree, but that's enough time spent on this feature for now. I agree, but that's enough time spent on this feature for now.
|
|||||||
|
resolve(buf);
|
||||||
Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/ Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/
Can use Can use `await`
I agree, but that's enough time spent on this feature for now. I agree, but that's enough time spent on this feature for now.
|
|||||||
|
});
|
||||||
Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/ Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/
Can use Can use `await`
I agree, but that's enough time spent on this feature for now. I agree, but that's enough time spent on this feature for now.
|
|||||||
|
}
|
||||||
Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/ Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/
Can use Can use `await`
I agree, but that's enough time spent on this feature for now. I agree, but that's enough time spent on this feature for now.
|
|||||||
|
});
|
||||||
Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/ Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/
Can use Can use `await`
I agree, but that's enough time spent on this feature for now. I agree, but that's enough time spent on this feature for now.
|
|||||||
|
} catch (e) {
|
||||||
Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/ Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/
Can use Can use `await`
I agree, but that's enough time spent on this feature for now. I agree, but that's enough time spent on this feature for now.
|
|||||||
|
logger.error(e);
|
||||||
Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/ Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/
Can use Can use `await`
I agree, but that's enough time spent on this feature for now. I agree, but that's enough time spent on this feature for now.
|
|||||||
|
reject(e);
|
||||||
Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/ Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/
Can use Can use `await`
I agree, but that's enough time spent on this feature for now. I agree, but that's enough time spent on this feature for now.
|
|||||||
|
}
|
||||||
Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/ Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/
Can use Can use `await`
I agree, but that's enough time spent on this feature for now. I agree, but that's enough time spent on this feature for now.
|
|||||||
|
});
|
||||||
Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/ Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/
Can use Can use `await`
I agree, but that's enough time spent on this feature for now. I agree, but that's enough time spent on this feature for now.
|
|||||||
|
};
|
||||||
Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/ Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/
Can use Can use `await`
I agree, but that's enough time spent on this feature for now. I agree, but that's enough time spent on this feature for now.
|
|||||||
|
|
||||||
Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/ Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/
Can use Can use `await`
I agree, but that's enough time spent on this feature for now. I agree, but that's enough time spent on this feature for now.
|
|||||||
|
function _cropCenter(path, cropWidth, cropHeight, originalWidth, originalHeight) {
|
||||||
Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/ Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/
Can use Can use `await`
I agree, but that's enough time spent on this feature for now. I agree, but that's enough time spent on this feature for now.
|
|||||||
|
let oAspect = originalWidth / originalHeight;
|
||||||
Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/ Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/
Can use Can use `await`
I agree, but that's enough time spent on this feature for now. I agree, but that's enough time spent on this feature for now.
|
|||||||
|
let cAspect = cropWidth / cropHeight;
|
||||||
Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/ Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/
Can use Can use `await`
I agree, but that's enough time spent on this feature for now. I agree, but that's enough time spent on this feature for now.
|
|||||||
|
let resizeX,
|
||||||
Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/ Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/
Can use Can use `await`
I agree, but that's enough time spent on this feature for now. I agree, but that's enough time spent on this feature for now.
|
|||||||
|
resizeY,
|
||||||
Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/ Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/
Can use Can use `await`
I agree, but that's enough time spent on this feature for now. I agree, but that's enough time spent on this feature for now.
|
|||||||
|
xpoint,
|
||||||
Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/ Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/
Can use Can use `await`
I agree, but that's enough time spent on this feature for now. I agree, but that's enough time spent on this feature for now.
|
|||||||
|
ypoint = null;
|
||||||
Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/ Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/
Can use Can use `await`
I agree, but that's enough time spent on this feature for now. I agree, but that's enough time spent on this feature for now.
|
|||||||
|
|
||||||
Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/ Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/
Can use Can use `await`
I agree, but that's enough time spent on this feature for now. I agree, but that's enough time spent on this feature for now.
|
|||||||
|
if (oAspect >= cAspect) {
|
||||||
Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/ Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/
Can use Can use `await`
I agree, but that's enough time spent on this feature for now. I agree, but that's enough time spent on this feature for now.
|
|||||||
|
// if crop is narrower aspect than original
|
||||||
Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/ Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/
Can use Can use `await`
I agree, but that's enough time spent on this feature for now. I agree, but that's enough time spent on this feature for now.
|
|||||||
|
resizeY = cropHeight;
|
||||||
Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/ Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/
Can use Can use `await`
I agree, but that's enough time spent on this feature for now. I agree, but that's enough time spent on this feature for now.
|
|||||||
|
xpoint = (oAspect * cropHeight) / 2 - cropWidth / 2;
|
||||||
Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/ Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/
Can use Can use `await`
I agree, but that's enough time spent on this feature for now. I agree, but that's enough time spent on this feature for now.
|
|||||||
|
ypoint = 0;
|
||||||
Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/ Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/
Can use Can use `await`
I agree, but that's enough time spent on this feature for now. I agree, but that's enough time spent on this feature for now.
|
|||||||
|
} else {
|
||||||
Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/ Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/
Can use Can use `await`
I agree, but that's enough time spent on this feature for now. I agree, but that's enough time spent on this feature for now.
|
|||||||
|
// if crop is wider aspect than original
|
||||||
Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/ Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/
Can use Can use `await`
I agree, but that's enough time spent on this feature for now. I agree, but that's enough time spent on this feature for now.
|
|||||||
|
resizeX = cropWidth;
|
||||||
Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/ Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/
Can use Can use `await`
I agree, but that's enough time spent on this feature for now. I agree, but that's enough time spent on this feature for now.
|
|||||||
|
xpoint = 0;
|
||||||
Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/ Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/
Can use Can use `await`
I agree, but that's enough time spent on this feature for now. I agree, but that's enough time spent on this feature for now.
|
|||||||
|
ypoint = cropWidth / oAspect / 2 - cropHeight / 2;
|
||||||
Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/ Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/
Can use Can use `await`
I agree, but that's enough time spent on this feature for now. I agree, but that's enough time spent on this feature for now.
|
|||||||
|
}
|
||||||
Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/ Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/
Can use Can use `await`
I agree, but that's enough time spent on this feature for now. I agree, but that's enough time spent on this feature for now.
|
|||||||
|
return new Promise((resolve, reject) => {
|
||||||
Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/ Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/
Can use Can use `await`
I agree, but that's enough time spent on this feature for now. I agree, but that's enough time spent on this feature for now.
|
|||||||
|
try {
|
||||||
Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/ Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/
Can use Can use `await`
I agree, but that's enough time spent on this feature for now. I agree, but that's enough time spent on this feature for now.
|
|||||||
|
imageMagick(path)
|
||||||
Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/ Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/
Can use Can use `await`
I agree, but that's enough time spent on this feature for now. I agree, but that's enough time spent on this feature for now.
|
|||||||
|
.resize(resizeX, resizeY)
|
||||||
Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/ Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/
Can use Can use `await`
I agree, but that's enough time spent on this feature for now. I agree, but that's enough time spent on this feature for now.
|
|||||||
|
.crop(cropWidth, cropHeight, xpoint, ypoint)
|
||||||
Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/ Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/
Can use Can use `await`
I agree, but that's enough time spent on this feature for now. I agree, but that's enough time spent on this feature for now.
|
|||||||
|
.toBuffer(null, (err, buf) => {
|
||||||
Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/ Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/
Can use Can use `await`
I agree, but that's enough time spent on this feature for now. I agree, but that's enough time spent on this feature for now.
|
|||||||
|
resolve(buf);
|
||||||
Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/ Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/
Can use Can use `await`
I agree, but that's enough time spent on this feature for now. I agree, but that's enough time spent on this feature for now.
|
|||||||
|
});
|
||||||
Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/ Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/
Can use Can use `await`
I agree, but that's enough time spent on this feature for now. I agree, but that's enough time spent on this feature for now.
|
|||||||
|
} catch (e) {
|
||||||
Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/ Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/
Can use Can use `await`
I agree, but that's enough time spent on this feature for now. I agree, but that's enough time spent on this feature for now.
|
|||||||
|
logger.error(e);
|
||||||
Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/ Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/
Can use Can use `await`
I agree, but that's enough time spent on this feature for now. I agree, but that's enough time spent on this feature for now.
|
|||||||
|
reject(e);
|
||||||
Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/ Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/
Can use Can use `await`
I agree, but that's enough time spent on this feature for now. I agree, but that's enough time spent on this feature for now.
|
|||||||
|
}
|
||||||
Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/ Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/
Can use Can use `await`
I agree, but that's enough time spent on this feature for now. I agree, but that's enough time spent on this feature for now.
|
|||||||
|
});
|
||||||
Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/ Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/
Can use Can use `await`
I agree, but that's enough time spent on this feature for now. I agree, but that's enough time spent on this feature for now.
|
|||||||
|
}
|
||||||
Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/ Can use a destructuring assignment, see https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/
Can use Can use `await`
I agree, but that's enough time spent on this feature for now. I agree, but that's enough time spent on this feature for now.
|
Can format like: