pdfbox-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andreas Lehmkuehler <andr...@lehmi.de>
Subject Re: Rendering images from PDF files slower in OpenJDK
Date Wed, 03 Oct 2018 20:31:05 GMT
Am 03.10.2018 um 21:14 schrieb Daniel Persson:
> Hi Tilman
> 
> Thank you for looking into this for me, I've run your code with different
> java versions and I can see the exact opposite time metrics.
> 
> In my initial test Java 8 was fastest, Java 9 was slowest and 10-11 was
> somewhere in the middle.
> 
> Maybe different color profiles are good at different images?
> Do you have any more suggestions?
Just a guess, but maybe you are comparing apples and oranges? It looks like 
Daniel is using Linux and AFAIK Tilman is using Windows. That could be the 
reason for the different results.

Andreas

> I'll report these findings to Oracle tomorrow.
> 
> Best regards
> Daniel
> 
> $ java -jar target/ColorConvTest-1.0-SNAPSHOT-jar-with-dependencies.jar
> Raster: ByteInterleavedRaster: width = 2577 height = 1540 #numDataElements
> 4 dataOff[0] = 0
> 60178
> 
> $ /opt/openjdk/jdk-9.0.4/bin/java -jar
> target/ColorConvTest-1.0-SNAPSHOT-jar-with-dependencies.jar
> Raster: ByteInterleavedRaster: width = 2577 height = 1540 #numDataElements
> 4 dataOff[0] = 0
> 33327
> 
> $ /opt/openjdk/jdk-10.0.2/bin/java -jar
> target/ColorConvTest-1.0-SNAPSHOT-jar-with-dependencies.jar
> Raster: ByteInterleavedRaster: width = 2577 height = 1540 #numDataElements
> 4 dataOff[0] = 0
> 56596
> 
> $ /opt/openjdk/jdk-11/bin/java -jar
> target/ColorConvTest-1.0-SNAPSHOT-jar-with-dependencies.jar
> Raster: ByteInterleavedRaster: width = 2577 height = 1540 #numDataElements
> 4 dataOff[0] = 0
> 56988
> 
> 
> On Wed, Oct 3, 2018 at 8:31 PM Tilman Hausherr <THausherr@t-online.de>
> wrote:
> 
>> Am 03.10.2018 um 20:08 schrieb Tilman Hausherr:
>>>
>>> I could expand that one later so that it uses the raster of the actual
>>> JPEG image from your PDF.
>>
>>
>> Your JPEG file is here:
>>
>>
>> https://drive.google.com/file/d/1HvXMet6Wygzmko9ZmY9_zlvhv72v_QHf/view?usp=sharing
>>
>> The modified code - please test on different openjdks. It took 137935 on
>> oracle jdk8. (you may want to change the "50")
>>
>>
>>
>> import java.awt.*;
>> import java.awt.color.*;
>> import java.awt.image.*;
>> import java.io.FileInputStream;
>> import javax.imageio.ImageIO;
>> import javax.imageio.ImageReadParam;
>> import javax.imageio.ImageReader;
>> import javax.imageio.stream.ImageInputStream;
>> import javax.imageio.stream.MemoryCacheImageInputStream;
>>
>> public class CConv
>> {
>>
>>       static BufferedImage toRGBImageAWT(WritableRaster raster,
>> ColorSpace colorSpace)
>>       {
>>
>>           ColorModel colorModel = new ComponentColorModel(colorSpace,
>>                   false, false, Transparency.OPAQUE,
>> raster.getDataBuffer().getDataType());
>>
>>           BufferedImage src = new BufferedImage(colorModel, raster,
>> false, null);
>>           BufferedImage dest = new BufferedImage(raster.getWidth(),
>> raster.getHeight(),
>>                   BufferedImage.TYPE_INT_RGB);
>>           ColorConvertOp op = new ColorConvertOp(null);
>>           //System.out.println("src="+src);
>>           //System.out.println("dst="+dest);
>>           op.filter(src, dest);
>>           return dest;
>>       }
>>
>>       public static void main(String args[]) throws Exception
>>       {
>>           ImageReader reader =
>> ImageIO.getImageReadersByFormatName("JPEG").next();
>>           WritableRaster raster;
>>           FileInputStream fis = new FileInputStream("cmyk.jpg");
>>           try (ImageInputStream iis = new MemoryCacheImageInputStream(fis))
>>           {
>>               reader.setInput(iis);
>>               ImageReadParam irp = reader.getDefaultReadParam();
>>               raster = (WritableRaster) reader.readRaster(0, irp);
>>           }
>>           System.out.println("Raster: " + raster);
>>
>>           ICC_Profile profile =
>> ICC_Profile.getInstance("ISOcoated_v2_300_bas.icc");
>>           ICC_ColorSpace colorSpace = new ICC_ColorSpace(profile);
>>           long t0 = System.currentTimeMillis();
>>           for (int i = 0; i < 50; i++)
>>           {
>>               toRGBImageAWT(raster, colorSpace);
>>           }
>>           long t1 = System.currentTimeMillis();
>>           System.out.println((t1 - t0));
>>       }
>> }
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@pdfbox.apache.org
>> For additional commands, e-mail: dev-help@pdfbox.apache.org
>>
>>
> 


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


Mime
View raw message