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 302432c commit 9052559
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## Unreleased

- Fixed aspect ratio for image with exif orientation tag

## 0.2.15 - 2024-11-02

- Added support PDF/A and PDF/UA (see [documentation](https://pdfmake.github.io/docs/0.1/document-definition-object/pdfa/))
Expand Down
11 changes: 10 additions & 1 deletion src/imageMeasure.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,16 @@ ImageMeasure.prototype.measureImage = function (src) {
image = this.pdfKitDoc._imageRegistry[src];
}

return { width: image.width, height: image.height };
var imageSize = { width: image.width, height: image.height };

if (typeof image === 'object' && 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 };
}
}

return imageSize;

function realImageSrc(src) {
var img = that.imageDictionary[src];
Expand Down

0 comments on commit 9052559

Please sign in to comment.