remove debugging
This commit is contained in:
parent
fd0d40c18e
commit
6554148d8a
@ -17,7 +17,6 @@ import {
|
|||||||
measureTextHeight,
|
measureTextHeight,
|
||||||
loadFont,
|
loadFont,
|
||||||
} from "jimp";
|
} from "jimp";
|
||||||
import log from "loglevel";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add Text To Image operation
|
* Add Text To Image operation
|
||||||
@ -212,10 +211,6 @@ class AddTextToImage extends Operation {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
let outlog = "";
|
|
||||||
outlog += `Adding text: "${text}" at (${xPos}, ${yPos}) with font: ${fontFace}, size: ${size}, colour: rgba(${red}, ${green}, ${blue}, ${alpha})\n`;
|
|
||||||
outlog += `Adding to image ${image.width}w, ${image.height}h\n`;
|
|
||||||
|
|
||||||
// Create a temporary image to hold the rendered text
|
// Create a temporary image to hold the rendered text
|
||||||
const textImage = new Jimp({
|
const textImage = new Jimp({
|
||||||
width: measureText(jimpFont, text),
|
width: measureText(jimpFont, text),
|
||||||
@ -227,7 +222,6 @@ class AddTextToImage extends Operation {
|
|||||||
y: 0,
|
y: 0,
|
||||||
text,
|
text,
|
||||||
});
|
});
|
||||||
outlog += `Rendered text image size: ${textImage.width}w, ${textImage.height}h\n`;
|
|
||||||
|
|
||||||
// Scale the rendered text image to the correct size
|
// Scale the rendered text image to the correct size
|
||||||
const scaleFactor = size / 72;
|
const scaleFactor = size / 72;
|
||||||
@ -245,7 +239,6 @@ class AddTextToImage extends Operation {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
outlog += `Scaled text image size: ${textImage.width}w, ${textImage.height}h\n`;
|
|
||||||
|
|
||||||
// If using the alignment options, calculate the pixel values AFTER the image has been scaled
|
// If using the alignment options, calculate the pixel values AFTER the image has been scaled
|
||||||
switch (hAlign) {
|
switch (hAlign) {
|
||||||
@ -259,7 +252,6 @@ class AddTextToImage extends Operation {
|
|||||||
xPos = image.width - textImage.width;
|
xPos = image.width - textImage.width;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
outlog += `Calculated xPos: ${xPos}\n`;
|
|
||||||
|
|
||||||
switch (vAlign) {
|
switch (vAlign) {
|
||||||
case "Top":
|
case "Top":
|
||||||
@ -272,8 +264,6 @@ class AddTextToImage extends Operation {
|
|||||||
yPos = image.height - textImage.height;
|
yPos = image.height - textImage.height;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
outlog += `Calculated yPos: ${yPos}\n`;
|
|
||||||
// throw new OperationError(outlog);
|
|
||||||
|
|
||||||
// Blit the rendered text image onto the original source image
|
// Blit the rendered text image onto the original source image
|
||||||
image.blit({
|
image.blit({
|
||||||
@ -290,12 +280,9 @@ class AddTextToImage extends Operation {
|
|||||||
}
|
}
|
||||||
return imageBuffer.buffer;
|
return imageBuffer.buffer;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
throw new OperationError(
|
throw new OperationError(`Error adding text to image. (${err})`, {
|
||||||
`Error adding text to image. (${err.stack})`,
|
|
||||||
{
|
|
||||||
cause: err,
|
cause: err,
|
||||||
},
|
});
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user