Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (106)
games submitted by our members
Games in WIP (533)
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 1950 times)
0 Members and 1 Guest are viewing this topic.
Offline appel

JGO Wizard


Medals: 50
Projects: 4


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!
Legends of Yore - The Casual Retro Roguelike
Offline appel

JGO Wizard


Medals: 50
Projects: 4


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.

 

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

The first screenshot will be displayed as a thumbnail.

pw (24 views)
2014-07-24 01:59:36

Riven (24 views)
2014-07-23 21:16:32

Riven (18 views)
2014-07-23 21:07:15

Riven (21 views)
2014-07-23 20:56:16

ctomni231 (50 views)
2014-07-18 06:55:21

Zero Volt (45 views)
2014-07-17 23:47:54

danieldean (36 views)
2014-07-17 23:41:23

MustardPeter (39 views)
2014-07-16 23:30:00

Cero (54 views)
2014-07-16 00:42:17

Riven (55 views)
2014-07-14 18:02:53
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
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!