Itai Shaked commented on PDFBOX-4137:

I will take some time to go over what you wrote, but in the meanwhile - maybe 
we need a better test case. I am attaching a file which is similar in 
characteristics to the ones I originally had problems with (sadly I cannot 
share the original files). The file is just the result of using imagemagick to 
convert this picture from Wikipedia to a PDF: 

Without the patch, on my machine, the debugger app takes about 1400ms to render 
it. With the patch, with subsampling disabled it takes about 950ms, so that's 
about 33% saved just from avoiding decoding twice (i.e. PDFBOX-3340).  Enabling 
subsampling, rendering at 100% goes down to about 200ms.   

I think you are correct and it will indeed be more elegant and safe to use your 
method and remove the meta-only part of the patch. I think when I started 
working on it I wasn't sure what info was needed for repair and in which cases. 

> Allow subsampled/downscaled rendering of images, and rendering subimages 
> -------------------------------------------------------------------------
>                 Key: PDFBOX-4137
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-4137
>             Project: PDFBox
>          Issue Type: Improvement
>          Components: Rendering
>    Affects Versions: 2.0.8
>            Reporter: Itai Shaked
>            Priority: Minor
>         Attachments: 0001-Image-render-subsample.patch, 067445.pdf, 
> image_rendering_subsampling_hack.patch, large-jpeg.pdf
> Suggested/contributed change to allow subsampling of images and rendering 
> sub-regions of images.  
> The need arises from having very large images which are highly compressed 
> (usually JPEG or JBIG2). The current implementation decodes the entire image 
> into memory at full resolution, even if rendering is done at a much lower 
> resolution. 
> Since the change required augmenting the way Filters work (to allow 
> partial/subsampled decoding), it also includes a partial fix for PDFBOX-3340. 
> This change introduces "DecodeOptions" which are currently only applicable 
> for images. They include requesting only metadata (for PDImageXObject's 
> repair method), subsampling and sub-region (similar to 
> javax.imagio.ImageReadParam). 
> Since not all filters can or do honor (use) the options, the DecodeOptions 
> class contains a flag. Filters that honor the options (subsample / decode 
> only requested region) set it to true. If the flag is false, the subsampling 
> or cropping should be done after decoding, to ensure consistency. 
> PageDrawer was modified so it uses subsampling based on the ratio of the 
> desired output to the original image. 

This message was sent by Atlassian JIRA

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

Reply via email to