pdfbox-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Persson <mailto.wo...@gmail.com>
Subject Re: Rendering images from PDF files slower in OpenJDK
Date Thu, 04 Oct 2018 05:56:36 GMT
Hi Tilman and Andreas

As we try different things I thought it good for collaboration to create a
repository with the code so all can contribute.

https://github.com/kalaspuffar/ColorConvTest

I've run the 3 different tests on my Machine (Thinkpad P51s) with custom
Gentoo installed, if important to the conversation.

I tried to invite you all as collaborators to this repository if you think
this is a bad Idea let me know.

Best regards
Daniel

On Wed, Oct 3, 2018 at 10:31 PM Andreas Lehmkuehler <andreas@lehmi.de>
wrote:

> 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
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message