diff --git a/seance.js b/seance.js index 6410777..ff602a0 100644 --- a/seance.js +++ b/seance.js @@ -8,6 +8,7 @@ const { createClient } = require('webdav') const readline = require('readline') const { markdown } = require('markdown') const GhostAdminAPI = require('@tryghost/admin-api') +const { Canvas, Image } = require('canvas') const Rembrandt = require('rembrandt') const config = require('./config') @@ -389,6 +390,25 @@ class Seance { return false } else { + /* First, check that the image has finished loading + * (we don't use this, because Rembrandt loads it again + * on its own, which is messy but what to do ¯\_(ツ)_/¯ + */ + + try { + let ctx = new Canvas().getContext('2d') + let img = new Image() + img.src = imagePath + ctx.drawImage(img, 0, 0, img.width, img.height) + } catch (err) { + this.emit('update', { + status: 'normal', + message: `[scissors] Skipping scissors check:${err.message}`, + loglevel: 'warning' + }) + return false + } + // Check if given image matches the scissors try { let isScissors = new Rembrandt({