Skip to content

[PDFBOX-5526] Adding subsampling for masks#147

Closed
velyan wants to merge 3 commits intoapache:trunkfrom
Canva:PDFBOX-5526
Closed

[PDFBOX-5526] Adding subsampling for masks#147
velyan wants to merge 3 commits intoapache:trunkfrom
Canva:PDFBOX-5526

Conversation

@velyan
Copy link

@velyan velyan commented Oct 31, 2022

See Jira ticket

When PDImageXObject.getImage() gets invoked with subsampling and region, internally it loads the entire mask into memory:

softMask.getOpaqueImage(), softMask.getInterpolate(), true, extractMatte(softMask));

and applies the entire mask on the subsampled image.

Which is extra work and can cause OOM exceptions.

The proposed optimisation is to pass region and subsampling params to PDImageXObject.getOpaqueImage() here -

public BufferedImage getOpaqueImage() throws IOException

such that masks are also subsampled before applying them...

Copy link
Contributor

@THausherr THausherr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're not passing the region despite having it as a parameter

@velyan
Copy link
Author

velyan commented Oct 31, 2022

You're not passing the region despite having it as a parameter

Thanks, fixed!

@velyan velyan requested a review from THausherr October 31, 2022 23:24
@velyan velyan closed this Nov 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants