Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

const Promise = require("bluebird");
const request = require("request");
const Canvas = require("canvas");
const fs = Promise.promisifyAll(require("fs"));
const { createCanvas, Canvas, Image } = require("canvas");

function downloadPhoto (uri) {
return new Promise((resolve, reject) => {
Expand Down Expand Up @@ -86,7 +86,7 @@ module.exports = function (options) {
const headerHeight = (options.header || {}).height || 0;
const canvasWidth = options.width * options.imageWidth + (options.width - 1) * (options.spacing);
const canvasHeight = headerHeight + options.height * options.imageHeight + (options.height - 1) * (options.spacing) + (options.textStyle.height || 200);
const canvas = new Canvas(canvasWidth, canvasHeight);
const canvas = createCanvas(canvasWidth, canvasHeight);

const ctx = canvas.getContext("2d");
ctx.fillStyle = options.backgroundColor;
Expand All @@ -103,7 +103,7 @@ module.exports = function (options) {
.each((photoBuffer, i) => {
if (i >= maxImages) return;

const img = new Canvas.Image();
const img = new Image();
img.src = photoBuffer;

if ((options.header || {}).image) { // only for header
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"homepage": "https://github.com/classdojo/photo-collage#readme",
"dependencies": {
"bluebird": "^3.3.5",
"canvas": "^1.3.15",
"canvas": "^2.6.1",
"request": "^2.72.0"
},
"devDependencies": {
Expand Down