Java-Gaming.org
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
Featured games (78)
games approved by the League of Dukes
Games in Showcase (406)
games submitted by our members
Games in WIP (292)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Fast and effecient way of scaling JPEG images?  (Read 1632 times)
0 Members and 1 Guest are viewing this topic.
Offline appel

JGO Ninja


Medals: 35
Projects: 5


I always win!


« Posted 2006-01-03 17:12:52 »

I haven't done any tests, but does anyone know how well java performs scaling like 2048x2048 (4-8mb) JPEG images down to like 640x480 and compress it down to 300-400 kb?

I'm thinking of an server application that would perform this operation 24/7, but I can't let it eat up all the memory or take many seconds for each image.

Here's what I need to do:

1. Open big image.
2. Scale down and compress.
3. Save smaller image to a new file on disk.

The reason I'm asking this is because I read some time ago that the java vm has limited memory regarding this, and I can't load huge jpeg images into memory?

Check out the 4K competition @ www.java4k.com
Check out GAMADU (my own site) @ http://gamadu.com/
Offline Raghar

Junior Member




Ue ni taete 'ru hitomi ni kono mi wa dou utsuru


« Reply #1 - Posted 2006-01-03 21:12:57 »

And how fast is your testing application, after warmup period?

2kB^2 = 4 MB * 3 = 12 MB isn't too much.

Are you reusing BufferedImages?
Offline pepijnve

Junior Member




Java games rock!


« Reply #2 - Posted 2006-01-04 10:34:40 »

For heavy image processing one of my colleagues uses JAI. I don't have any numbers, but I would expect it to outperform BufferedImages.
Games published by our own members! Check 'em out!
Try the Free Demo of Revenge of the Titans
Offline appel

JGO Ninja


Medals: 35
Projects: 5


I always win!


« Reply #3 - Posted 2006-01-04 10:41:05 »

Thanks, I'll take a look at JAI.

Check out the 4K competition @ www.java4k.com
Check out GAMADU (my own site) @ http://gamadu.com/
Offline pepijnve

Junior Member




Java games rock!


« Reply #4 - Posted 2006-01-04 11:12:55 »

Just found a post on JAI performance. It doesn't look good, so I take back my original post  Embarrassed
Offline Raghar

Junior Member




Ue ni taete 'ru hitomi ni kono mi wa dou utsuru


« Reply #5 - Posted 2006-01-04 21:10:28 »

And answer to my questions is...

BTW these are somewhat strange numbers. 4 MPi Jpegs with 4-8 MB size. Either they are lossles, or with insanely low quantitization. In fact lossless compression with BZX might be better nearly always. And BZX is general purpose data analisys program that's able to shrink files with some regularity.
640 x 480 *3 ~= 800 kB uncompressed. In fact lossy codec as JPEG should be able to drop theirs size to 58-98 kB without any effort.

So few other questions.
What is speed of loading the image into memory?
What is speed of the disk?
Are you using Bsplines, or Lancos filter for downsampling?
What is speed of memory of the server?
What is network latency, and are you doing them in parallel?
Offline arne

Senior Member




money is the worst drug- we should not let it rule


« Reply #6 - Posted 2006-01-05 15:33:49 »

You'll get problems dealing with 4mb jpegs.
4mb doesn't sound much, but as jpeg it's compressed very much, so uncompressed it might be above 50mb and then the default java memory is not enough.
But if you think this is a serious problem, simply start java with java -mx200m.

:: JOODE :: Xith3d :: OdeJava ::
Offline Mark Thornton

Senior Member





« Reply #7 - Posted 2006-01-07 17:58:00 »

Try using the imageio package (javax.imageio). This allows you to read an image and reduce its size in a single step. Depending on the implementation this may not require as much memory as would be required to read in the entire original image. The downside is that the quality of rescaling is likely yo be reduced. Alternatively it also allows you to read in parts of an image, so you could divide the larger image into many pieces and rescale each separately (you will need some overlap) and finally recombine the reduced pieces.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Browse for soundtracks for your game!

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

The invasion has landed! On Mars! And you're there to beat 'em!
cubemaster21 (67 views)
2013-05-17 21:29:12

alaslipknot (76 views)
2013-05-16 21:24:48

gouessej (109 views)
2013-05-16 00:53:38

gouessej (104 views)
2013-05-16 00:17:58

theagentd (115 views)
2013-05-15 15:01:13

theagentd (104 views)
2013-05-15 15:00:54

StreetDoggy (149 views)
2013-05-14 15:56:26

kutucuk (172 views)
2013-05-12 17:10:36

kutucuk (170 views)
2013-05-12 15:36:09

UnluckyDevil (179 views)
2013-05-12 05:09:57
Complex number cookbook
by Roquen
2013-04-24 12:47:31

2D Dynamic Lighting
by Oskuro
2013-04-17 16:46:12

2D Dynamic Lighting
by Oskuro
2013-04-17 16:45:57

2D Dynamic Lighting
by Oskuro
2013-04-17 16:23:20

Noise (bandpassed white)
by Roquen
2013-04-05 17:36:01

Noise (bandpassed white)
by Roquen
2013-04-03 16:17:38

Java Data structures
by Roquen
2013-03-29 13:21:12

Topic Request
by kutucuk
2013-03-22 21:42:01
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!
Page created in 0.097 seconds with 21 queries.