Skip to content

Commit

Permalink
fix for #693 (#706)
Browse files Browse the repository at this point in the history
Co-authored-by: Lucas Cimon <925560+Lucas-C@users.noreply.github.com>
  • Loading branch information
eroux and Lucas-C authored Feb 23, 2023
1 parent 907052c commit 5a2cb13
Show file tree
Hide file tree
Showing 9 changed files with 352 additions and 16 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*.p12 binary
*.otf binary
*.ttf binary
*.TTF binary
*.bmp binary
*.jpg binary
*.gif binary
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ This can also be enabled programmatically with `warnings.simplefilter('default',
### Changed
- vector images parsing is now more robust: `fpdf2` can now embed SVG files without `viewPort` or no `height` / `width`
- bitonal images are now encoded using `CCITTFaxDecode`, reducing their size in the PDF document - thanks to @eroux
- when possible, JPG and group4 encoded TIFFs are now embedded directly without recompression - thanks to @eroux

## [2.6.1] - 2023-01-13
### Added
Expand Down
10 changes: 5 additions & 5 deletions fpdf/fpdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -3716,9 +3716,7 @@ def preload_image(self, name, dims=None):
if info:
info["usages"] += 1
else:
if not img:
img = load_image(name)
info = ImageInfo(get_img_info(img, self.image_filter, dims))
info = ImageInfo(get_img_info(name, img, self.image_filter, dims))
info["i"] = len(self.images) + 1
info["usages"] = 1
self.images[name] = info
Expand Down Expand Up @@ -3836,7 +3834,7 @@ def _downscale_image(self, name, img, info, w, h):
# The existing low-res image is too small, we need a bigger low-res image:
info.update(
get_img_info(
img or load_image(name), self.image_filter, dims
name, img or load_image(name), self.image_filter, dims
)
)
LOGGER.debug(
Expand All @@ -3848,7 +3846,9 @@ def _downscale_image(self, name, img, info, w, h):
info["usages"] += 1
else:
info = ImageInfo(
get_img_info(img or load_image(name), self.image_filter, dims)
get_img_info(
name, img or load_image(name), self.image_filter, dims
)
)
info["i"] = len(self.images) + 1
info["usages"] = 1
Expand Down
Loading

0 comments on commit 5a2cb13

Please sign in to comment.