Don't freak out if one of the pics hasn't loaded

Instead of throwing up hands in despair, Seance will now simply
ignore the badly loaded image and carry on.
This commit is contained in:
Badri Sunderarajan 2021-01-09 18:22:53 +05:30
parent a35d6195cf
commit 22664a7d44

View file

@ -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({