Skip to content

Commit

Permalink
fixed aspect ratio for image with exif orientation tag #2316
Browse files Browse the repository at this point in the history
  • Loading branch information
liborm85 committed Nov 6, 2024
1 parent 41f9dde commit be1bf25
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Unreleased

- Fixed speed in Node.js if is fetching URL for image or font redirected
- Fixed aspect ratio for image with exif orientation tag

## 0.3.0-beta.12 - 2024-11-03

Expand Down
8 changes: 8 additions & 0 deletions src/DocMeasure.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,16 @@ class DocMeasure {
this.convertIfBase64Image(node);

let image = this.pdfDocument.provideImage(node.image);

let imageSize = { width: image.width, height: image.height };

if (image.constructor.name === 'JPEG') {
// If EXIF orientation calls for it, swap width and height
if (image.orientation > 4) {
imageSize = { width: image.height, height: image.width };
}
}

this.measureImageWithDimensions(node, imageSize);

return node;
Expand Down

0 comments on commit be1bf25

Please sign in to comment.