mozjpeg icon indicating copy to clipboard operation
mozjpeg copied to clipboard

JAVA api

Open shailenderjain opened this issue 6 years ago • 8 comments

Hello, I could not find any option to use Java API to pass my custom quantization table (-qtable), -notrellis options. Is there any option available....

shailenderjain avatar Jul 30 '18 07:07 shailenderjain

Probably not. We haven't kept the Java API up to date with MozJPEG changes.

It shouldn't be too hard to add it — have a look how other settings are implemented, and create similar methods for the missing ones.

kornelski avatar Jul 30 '18 10:07 kornelski

  1. I will implement the same by adding flags for -notrellis in TJ class

I have another query: We want to create 3 versions of the same image at the quality level of 75, 84 and 90. Users will select the right version after visual inspection. However, it takes more then a minute for file size of approx. 3 MB. Is there any option to improve the performance. Any idea will be helpful (Other then hardware improvement)

shailenderjain avatar Aug 01 '18 06:08 shailenderjain

It should take seconds, not minutes.

When you use cjpeg command that you built yourself, is it also that slow, or is it slow only via Java API?

kornelski avatar Aug 01 '18 11:08 kornelski

When i use CJPEG it takes approx. 25 seconds for 1 iteration. I have to execute 3 iterations (75, 84 & 90). Hence, approx 1 minute to complete

shailenderjain avatar Aug 01 '18 11:08 shailenderjain

You should expect a speed of about 5-10 megapixels per second, so unless your image was HUUUGE, there's something wrong with your compilation.

Did you disable SIMD? Did you compile in debug mode or disable optimizations?

kornelski avatar Aug 01 '18 13:08 kornelski

These were the steps

  1. sudo apt-get install autoconf automake libtool nasm make pkg-config git
  2. git clone https://github.com/mozilla/mozjpeg.git
  3. cd mozjpeg
  4. autoreconf -fiv
  5. ./configure --with-java
  6. make

Is there something missing? Let me know if i need to reinstall

shailenderjain avatar Aug 01 '18 13:08 shailenderjain

That looks ok. In that case I don't understand why it's slow.

kornelski avatar Aug 01 '18 13:08 kornelski

If you need 3 versions, you can run them on 3 threads. The library is single-threaded, and most CPUs are multicore, so you should get a nice 3x speedup.

kornelski avatar Aug 01 '18 13:08 kornelski