voole / thumbnailator

Automatically exported from code.google.com/p/thumbnailator
Other
0 stars 0 forks source link

Handle large image files in an memory-efficient manner #1

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Problem
-------
* Currently, Thumbnailator does not have good support for large image files.

For example, there is no protection against running out of memory, and this 
behavior is completely dependent upon the JVM's memory settings.

Solution
--------
* Support tiled reading of image files, rather than reading the entire files at 
once, as is implemented currently.

Complications
-------------
* Changes to support reading images by tiles will most likely lead to changes 
to the API.

Original issue reported on code.google.com by coobird...@gmail.com on 22 Sep 2010 at 4:28

GoogleCodeExporter commented 9 years ago
The most likely place to add support for this feature is the `ThumbnailTask` 
interface.

The `read` method (and possibly `write` method) would be changed to return 
image tiles, rather than a single `BufferedImage`.

This change would affect a fairly significant portion of Thumbnailator.

This feature is not expected to be in the Thumbnailator 0.3.0 release.

Original comment by coobird...@gmail.com on 23 Dec 2010 at 4:53

GoogleCodeExporter commented 9 years ago

Original comment by coobird...@gmail.com on 11 Feb 2012 at 7:17

GoogleCodeExporter commented 9 years ago

Original comment by coobird...@gmail.com on 26 Feb 2012 at 6:25

GoogleCodeExporter commented 9 years ago
I don't think this issue has a priority Low. I got a lot of 
OutOfMemoryException when processing large images and so i can't use this lib. 
This is a shame because I found your library very well shaped in term of usage.

Do you think you can move on ?

Original comment by thomas.bruyelle@gmail.com on 21 Sep 2012 at 8:25

GoogleCodeExporter commented 9 years ago
It's interesting that this issue was brought up again, as I've actually been 
seriously considering putting this issue at a higher priority -- I've also 
noticed some blog postings where people were encountering `OutOfMemoryError`s, 
so I suspect there are quite a few people out there who are having the same 
problem.

In the past week, I have started experimenting with an approach to reduce 
memory usage.
(It's a different approach from the idea I had two years ago, but it will 
require a little bit of rework, but very unlikely to cause any problems with 
existing code.)

I can't make any promises, but hopefully I will be able to address this issue 
in a not-so-distant release.

Original comment by coobird...@gmail.com on 23 Sep 2012 at 3:02

GoogleCodeExporter commented 9 years ago
I managed to fix my issue by increasing the JVM memory (-Xms512m -Xmx512m). 

I didn't try with very large image (50k x 50k for instance) but Thumbnailator 
works very well with standard image size (less than 10mo) if you increase the 
JVM memory.

Thanks for your work on this project, Thumbnailator is great.

Original comment by thomas.bruyelle@gmail.com on 24 Sep 2012 at 8:07

GoogleCodeExporter commented 9 years ago
There seems to be issues with Java 7 Update 21 causing `OutOfMemoryError`s more 
frequently than previous versions/updates of Java.

Java 7 Update 21 is the current version of Java at this point in time.

I may need to look into increasing the priority of this issue.

Original comment by coobird...@gmail.com on 12 May 2013 at 3:00

GoogleCodeExporter commented 9 years ago
The `OutOfMemoryError` issue with Java 7 Update 21 was a separate, *unrelated* 
issue that was caused by the incorrect handling of resources (not disposing 
`ImageReader`s and `ImageWriter`s after using it) which lead to some kind of 
memory leak.

That `OutOfMemoryError` issue has been fixed in Issue 42 and released as part 
of Thumbnailator 0.4.4.

----

Issue 1 will be tackling the issue of dealing with how to reduce the amount of 
memory being used when the thumbnail image is being generated.

Original comment by coobird...@gmail.com on 2 Jun 2013 at 12:12

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Hi,

I am encountering this issue even with the latest Thumbnailator-0.4.7-all.jar

Here is the exception that I get

java.lang.OutOfMemoryError: Java heap space
    at java.awt.image.DataBufferByte.<init>(DataBufferByte.java:42)
    at java.awt.image.Raster.createInterleavedRaster(Raster.java:253)
    at java.awt.image.BufferedImage.<init>(BufferedImage.java:365)
    at net.coobird.thumbnailator.resizers.ProgressiveBilinearResizer.resize(Unknown Source)
    at net.coobird.thumbnailator.resizers.Resizers.resize(Unknown Source)
    at net.coobird.thumbnailator.makers.ThumbnailMaker.makeThumbnail(Unknown Source)
    at net.coobird.thumbnailator.makers.FixedSizeThumbnailMaker.make(Unknown Source)
    at net.coobird.thumbnailator.Thumbnailator.createThumbnail(Unknown Source)

Do you have any plans to address this issue?

Thanks

Original comment by M.Kirkus...@gmail.com on 29 Apr 2014 at 11:23

GoogleCodeExporter commented 9 years ago
Wow! That's the same issue I just encountered.

java.lang.OutOfMemoryError: Java heap space
    at java.awt.image.DataBufferByte.<init>(DataBufferByte.java:42)
    at java.awt.image.Raster.createInterleavedRaster(Raster.java:253)
    at java.awt.image.BufferedImage.<init>(BufferedImage.java:365)

Iam using net.coobird 0.4.7 as well. Hope someone can solve this problem.

Original comment by alleni...@gmail.com on 29 Apr 2014 at 3:08

GoogleCodeExporter commented 9 years ago
I am glad I am not the only with this issue :).

Original comment by M.Kirkus...@gmail.com on 29 Apr 2014 at 4:52

GoogleCodeExporter commented 9 years ago
I'm considering creating a temporary workaround (which should work 
transparently without user intervention) that should prevent most of the 
`OutOfMemoryError`s that I believe users are experiencing.

The temporary workaround will be implemented as described in Issue 69.

Original comment by coobird...@gmail.com on 4 May 2014 at 5:39

GoogleCodeExporter commented 9 years ago
Sometimes it also happens when reading the image:

java.lang.OutOfMemoryError: Java heap space
    at java.awt.image.DataBufferByte.<init>(DataBufferByte.java:58)
    at java.awt.image.ComponentSampleModel.createDataBuffer(ComponentSampleModel.java:397)
    at java.awt.image.Raster.createWritableRaster(Raster.java:938)
    at javax.imageio.ImageTypeSpecifier.createBufferedImage(ImageTypeSpecifier.java:1056)
    at javax.imageio.ImageReader.getDestination(ImageReader.java:2879)
    at com.sun.imageio.plugins.jpeg.JPEGImageReader.readInternal(JPEGImageReader.java:943)
    at com.sun.imageio.plugins.jpeg.JPEGImageReader.read(JPEGImageReader.java:915)
    at javax.imageio.ImageReader.read(ImageReader.java:923)
    at net.coobird.thumbnailator.tasks.io.InputStreamImageSource.read(Unknown Source)
    at net.coobird.thumbnailator.tasks.SourceSinkThumbnailTask.read(Unknown Source)
    at net.coobird.thumbnailator.Thumbnailator.createThumbnail(Unknown Source)

Original comment by M.Kirkus...@gmail.com on 5 May 2014 at 5:27

GoogleCodeExporter commented 9 years ago
The Thumbnailator project will move to GitHub due to Google Project Hosting 
going read-only in one month.
http://google-opensource.blogspot.jp/2015/03/farewell-to-google-code.html

This issue has been migrated to GitHub at the following URL:
https://github.com/coobird/thumbnailator/issues/1

Original comment by coobird...@gmail.com on 25 Jul 2015 at 11:42