Discussion:
[Libjpeg-turbo-users] TJCompressor for more than 300 images
Ivan Ooi
2016-03-14 17:14:56 UTC
Permalink
Hi all,

I'm try to use TJCompressor to compress more than 300 images but it is
easily out of memory heap size.

Is there anyway to over come this issues ?

Thanks
Ivan

This is my test code :

TJCompressor tjc = new TJCompressor();

tjc.setSourceImage(abi_image,0,0,abi_image.getWidth(),
abi_image.getHeight() );

tjc.setJPEGQuality(70);
tjc.setSubsamp(TJ.SAMP_420);

byte lbyt_image2[] = tjc.compress( ii_compress_flags );
tjc.close();
tjc = null ;
System.gc();
DRC
2016-03-14 17:29:02 UTC
Permalink
You're doing exactly what I would do. Not sure why the garbage
collector isn't working properly. The next things I would try:

(1) Allocate the TJCompressor instance statically and reuse it for
every subsequent image.

(2) If you know that the output image will never exceed a particular
size, then allocate it statically with size TJ.bufSize(maxWidth,
maxHeight, TJ.SAMP_420) and reuse the same output buffer for every image
(compress(byte[] dstBuf, int flags).) Even if the image size is
variable, then you could allocate the buffer statically with the
dimensions of the first image and re-allocate it only when a subsequent
image exceeds those dimensions.
Post by Ivan Ooi
Hi all,
I'm try to use TJCompressor to compress more than 300 images but it is
easily out of memory heap size.
Is there anyway to over come this issues ?
Thanks
Ivan
TJCompressor tjc = new TJCompressor();
tjc.setSourceImage(abi_image,0,0,abi_image.getWidth(),
abi_image.getHeight() );
tjc.setJPEGQuality(70);
tjc.setSubsamp(TJ.SAMP_420);
byte lbyt_image2[] = tjc.compress( ii_compress_flags );
tjc.close();
tjc = null ;
System.gc();
Ivan Ooi
2016-03-14 17:51:55 UTC
Permalink
just tested your way. init TJCompressor 1 time. and reuse it.

1st time i call
tjc_byte = tjc.compress( ii_compress_flags );

then call the following for rest :
tjc.compress( tjc_byte, ii_compress_flags );

and every time i will call tjc.close();
but still no luck...

still, 33 photos only and out of heap size...
Post by DRC
You're doing exactly what I would do. Not sure why the garbage
(1) Allocate the TJCompressor instance statically and reuse it for
every subsequent image.
(2) If you know that the output image will never exceed a particular
size, then allocate it statically with size TJ.bufSize(maxWidth,
maxHeight, TJ.SAMP_420) and reuse the same output buffer for every image
(compress(byte[] dstBuf, int flags).) Even if the image size is
variable, then you could allocate the buffer statically with the
dimensions of the first image and re-allocate it only when a subsequent
image exceeds those dimensions.
Post by Ivan Ooi
Hi all,
I'm try to use TJCompressor to compress more than 300 images but it is
easily out of memory heap size.
Is there anyway to over come this issues ?
Thanks
Ivan
TJCompressor tjc = new TJCompressor();
tjc.setSourceImage(abi_image,0,0,abi_image.getWidth(),
abi_image.getHeight() );
tjc.setJPEGQuality(70);
tjc.setSubsamp(TJ.SAMP_420);
byte lbyt_image2[] = tjc.compress( ii_compress_flags );
tjc.close();
tjc = null ;
System.gc();
------------------------------------------------------------------------------
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785231&iu=/4140
_______________________________________________
Libjpeg-turbo-users mailing list
https://lists.sourceforge.net/lists/listinfo/libjpeg-turbo-users
DRC
2016-03-14 19:06:40 UTC
Permalink
No clue. Sorry.
Post by Ivan Ooi
just tested your way. init TJCompressor 1 time. and reuse it.
1st time i call
tjc_byte = tjc.compress( ii_compress_flags );
tjc.compress( tjc_byte, ii_compress_flags );
and every time i will call tjc.close();
but still no luck...
still, 33 photos only and out of heap size...
You're doing exactly what I would do. Not sure why the garbage
(1) Allocate the TJCompressor instance statically and reuse it for
every subsequent image.
(2) If you know that the output image will never exceed a particular
size, then allocate it statically with size TJ.bufSize(maxWidth,
maxHeight, TJ.SAMP_420) and reuse the same output buffer for every image
(compress(byte[] dstBuf, int flags).) Even if the image size is
variable, then you could allocate the buffer statically with the
dimensions of the first image and re-allocate it only when a subsequent
image exceeds those dimensions.
Post by Ivan Ooi
Hi all,
I'm try to use TJCompressor to compress more than 300 images but it is
easily out of memory heap size.
Is there anyway to over come this issues ?
Thanks
Ivan
TJCompressor tjc = new TJCompressor();
tjc.setSourceImage(abi_image,0,0,abi_image.getWidth(),
abi_image.getHeight() );
tjc.setJPEGQuality(70);
tjc.setSubsamp(TJ.SAMP_420);
byte lbyt_image2[] = tjc.compress( ii_compress_flags );
tjc.close();
tjc = null ;
System.gc();
------------------------------------------------------------------------------
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785231&iu=/4140
_______________________________________________
Libjpeg-turbo-users mailing list
https://lists.sourceforge.net/lists/listinfo/libjpeg-turbo-users
------------------------------------------------------------------------------
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785231&iu=/4140
_______________________________________________
Libjpeg-turbo-users mailing list
https://lists.sourceforge.net/lists/listinfo/libjpeg-turbo-users
Ivan Ooi
2016-03-15 04:17:18 UTC
Permalink
is ok... thanks for your feedback.hopefully this matters alerts others...
Post by DRC
No clue. Sorry.
Post by Ivan Ooi
just tested your way. init TJCompressor 1 time. and reuse it.
1st time i call
tjc_byte = tjc.compress( ii_compress_flags );
tjc.compress( tjc_byte, ii_compress_flags );
and every time i will call tjc.close();
but still no luck...
still, 33 photos only and out of heap size...
You're doing exactly what I would do. Not sure why the garbage
(1) Allocate the TJCompressor instance statically and reuse it for
every subsequent image.
(2) If you know that the output image will never exceed a particular
size, then allocate it statically with size TJ.bufSize(maxWidth,
maxHeight, TJ.SAMP_420) and reuse the same output buffer for every
image
Post by Ivan Ooi
(compress(byte[] dstBuf, int flags).) Even if the image size is
variable, then you could allocate the buffer statically with the
dimensions of the first image and re-allocate it only when a
subsequent
Post by Ivan Ooi
image exceeds those dimensions.
Post by Ivan Ooi
Hi all,
I'm try to use TJCompressor to compress more than 300 images but
it is
Post by Ivan Ooi
Post by Ivan Ooi
easily out of memory heap size.
Is there anyway to over come this issues ?
Thanks
Ivan
TJCompressor tjc = new TJCompressor();
tjc.setSourceImage(abi_image,0,0,abi_image.getWidth(),
Post by Ivan Ooi
Post by Ivan Ooi
abi_image.getHeight() );
tjc.setJPEGQuality(70);
tjc.setSubsamp(TJ.SAMP_420);
byte lbyt_image2[] = tjc.compress(
ii_compress_flags );
Post by Ivan Ooi
Post by Ivan Ooi
tjc.close();
tjc = null ;
System.gc();
------------------------------------------------------------------------------
Post by Ivan Ooi
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785231&iu=/4140
_______________________________________________
Libjpeg-turbo-users mailing list
https://lists.sourceforge.net/lists/listinfo/libjpeg-turbo-users
------------------------------------------------------------------------------
Post by Ivan Ooi
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785231&iu=/4140
_______________________________________________
Libjpeg-turbo-users mailing list
https://lists.sourceforge.net/lists/listinfo/libjpeg-turbo-users
------------------------------------------------------------------------------
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785231&iu=/4140
_______________________________________________
Libjpeg-turbo-users mailing list
https://lists.sourceforge.net/lists/listinfo/libjpeg-turbo-users
Loading...