You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by GitBox <gi...@apache.org> on 2022/10/31 05:25:07 UTC

[GitHub] [pdfbox] velyan opened a new pull request, #147: [PDFBOX-5526] Adding subsampling for masks

velyan opened a new pull request, #147:
URL: https://github.com/apache/pdfbox/pull/147

   See[ Jira ticket ](https://issues.apache.org/jira/browse/PDFBOX-5526?page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel&focusedCommentId=17618666#comment-17618666)
   
   When `PDImageXObject.getImage()` gets invoked with subsampling and region, internally it loads the entire mask into memory: https://github.com/apache/pdfbox/blob/961c052d52dd9ab2dd3d7cd762a5046e5cc85a91/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/PDImageXObject.java#L465
   
   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 - https://github.com/apache/pdfbox/blob/961c052d52dd9ab2dd3d7cd762a5046e5cc85a91/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/PDImageXObject.java#L548
   
   such that masks are also subsampled before applying them...


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@pdfbox.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: dev-help@pdfbox.apache.org


[GitHub] [pdfbox] velyan commented on pull request #147: [PDFBOX-5526] Adding subsampling for masks

Posted by GitBox <gi...@apache.org>.
velyan commented on PR #147:
URL: https://github.com/apache/pdfbox/pull/147#issuecomment-1297808996

   > You're not passing the region despite having it as a parameter
   
   Thanks, fixed!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@pdfbox.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: dev-help@pdfbox.apache.org


[GitHub] [pdfbox] lehmi commented on a diff in pull request #147: [PDFBOX-5526] Adding subsampling for masks

Posted by GitBox <gi...@apache.org>.
lehmi commented on code in PR #147:
URL: https://github.com/apache/pdfbox/pull/147#discussion_r1009187853


##########
pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/PDImageXObject.java:
##########
@@ -542,18 +542,22 @@ public BufferedImage getStencilImage(Paint paint) throws IOException
     /**
      * Returns an RGB buffered image containing the opaque image stream without any masks applied.
      * If this Image XObject is a mask then the buffered image will contain the raw mask.
+     * @param region The region of the source image to get, or null if the entire image is needed.
+     *               The actual region will be clipped to the dimensions of the source image.
+     * @param subsampling The amount of rows and columns to advance for every output pixel, a value
+     * of 1 meaning every pixel will be read. It must not be larger than the image width or height.
      * @return the image without any masks applied
      * @throws IOException if the image cannot be read
      */
-    public BufferedImage getOpaqueImage() throws IOException
+    public BufferedImage getOpaqueImage(Rectangle region, int subsampling) throws IOException
     {
-        return SampledImageReader.getRGBImage(this, null);
+        return SampledImageReader.getRGBImage(this, null, subsampling, null);

Review Comment:
   The region isn't passed to getRGBImage



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@pdfbox.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: dev-help@pdfbox.apache.org


[GitHub] [pdfbox] velyan closed pull request #147: [PDFBOX-5526] Adding subsampling for masks

Posted by GitBox <gi...@apache.org>.
velyan closed pull request #147: [PDFBOX-5526] Adding subsampling for masks
URL: https://github.com/apache/pdfbox/pull/147


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@pdfbox.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: dev-help@pdfbox.apache.org