Skip to content

Commit

Permalink
Fix image padding (#1015)
Browse files Browse the repository at this point in the history
  • Loading branch information
BritishWerewolf authored Nov 25, 2024
1 parent 23647e2 commit 1768b8b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/utils/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -428,13 +428,14 @@ export class RawImage {
// Draw image to context, padding in the process
ctx.drawImage(canvas,
0, 0, this.width, this.height,
left, top, newWidth, newHeight
left, top, this.width, this.height
);

// Create image from the padded data
const paddedImage = new RawImage(
ctx.getImageData(0, 0, newWidth, newHeight).data,
newWidth, newHeight, 4);
newWidth, newHeight, 4
);

// Convert back so that image has the same number of channels as before
return paddedImage.convert(numChannels);
Expand Down

0 comments on commit 1768b8b

Please sign in to comment.