1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-06-15 23:00:36 +02:00

Clipper: Resolves #681: Allow adding tags from Web Clipper

This commit is contained in:
Laurent Cozic
2018-09-23 18:03:11 +01:00
parent e7a12bb0dd
commit 77f089654e
7 changed files with 158 additions and 26 deletions

View File

@ -173,7 +173,16 @@ function shimInit() {
if (shim.isElectron()) {
const nativeImage = require('electron').nativeImage;
let image = nativeImage.createFromDataURL(imageDataUrl);
if (options.cropRect) image = image.crop(options.cropRect);
if (image.isEmpty()) throw new Error('Could not convert data URL to image');
if (options.cropRect) {
// Crop rectangle values need to be rounded or the crop() call will fail
const c = options.cropRect;
if ('x' in c) c.x = Math.round(c.x);
if ('y' in c) c.y = Math.round(c.y);
if ('width' in c) c.width = Math.round(c.width);
if ('height' in c) c.height = Math.round(c.height);
image = image.crop(c);
}
const mime = mimeUtils.fromDataUrl(imageDataUrl);
await shim.writeImageToFile(image, mime, filePath);
} else {