• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Resizing JPG using Graphics2D

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

I have the following code to resize the images.



I tried to resize these 2 photos -

pic1.jpg: JFIF standard 1.02, 4200x2800, 1.5 MB
pic2.jpg: EXIF standard, 2500x1900, 1.8 MB



It took a few seconds (3, 4 sec) to resize pic2.jpg but took more than one minute to resize pic1.jpg.

Is there any way to improve the performance the above code snippet?

Which attribute decide the performance of image resizing?
Is is the size of the image? or the resolution? or the encoding? or any other criteria?


Your advice would be really appreciated because I don't have much experience in image processing.


Thanks and regards
Terence

 
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
try googling AffineTransformOp
 
Marshal
Posts: 75664
354
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To expand about AffineTransforms: you can scale, translate, rotate or shear your Graphics object. Either use the AffineTransform class or those methods in the Graphics2Dclass.

Beware: because of the imprecision of floating-point arithmetic it is difficult to undo a transform (shear is the worst offender), so you are probably better off using a copy Graphics object from the create method of the graphics classes.
 
a fool thinks himself to be wise, but a wise man knows himself to be a fool - shakespeare. foolish tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic