1

I am working with images in Java. I have a set of images - let's say 600x800 pixels each. I resize them at 100x100 and I make some stuff on it. Now I would like to enlarge the image at the beginning size without losing my changing and pixel quality. Is this possible?

Michael Petrotta
  • 59,888
  • 27
  • 145
  • 179
Gianfra
  • 1,119
  • 4
  • 17
  • 33
  • 1
    By nature, if you make changes at the 100x100 level, and then expand it back to 600x800, the quality of the changes will be reduced, even if not the original image itself. – gkiar Feb 14 '12 at 17:29

2 Answers2

5

No. This also isn't really a Java question. How would you do this with an image editor? If you resize twice (especially smaller than larger), you're going to lose quality.

Your best bet is to keep the native resolution, then use vector graphics to draw what you need - eliminating any unnecessary resizing. (I.E., calculate what you need to draw, taking into account the current size - without first resizing to 100x100.) This will also fix some issues you're also probably seeing regarding the aspect ratios - as when you would resize from 100x100 back to 600x800, whatever you added is going to appear "stretched" / wider.

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
ziesemer
  • 27,712
  • 8
  • 86
  • 94
  • i need to resize because i apply a color algorithm. it looks every pixel of the image, for this i wanted to resize because smaller is faster :) i think this is not possible. So i should think about something else – Gianfra Feb 14 '12 at 17:38
  • 1
    *"smaller is faster"* Research 'premature optimization'. – Andrew Thompson Feb 15 '12 at 00:09
0

I would like to enlarge the image at the beginning size without losing my changing and pixel quality. Is this possible?

Yes, it's possible and very simple.

Here's how you do it: use your original.

Matt Brock
  • 5,337
  • 1
  • 27
  • 26
  • i woulndt ask if i could use the original ones – Gianfra Feb 14 '12 at 23:33
  • Unfortunately that is your only choice. You can't create data out of thin air. Take your example to its limits and ask the question again: what if you had a 1000x1000 image that was reduced to a single pixel? What you are asking is akin to asking how you can go back from a single pixel to a 1000x1000 image. You can't. Once you throw away the data it is gone. If you were using lossless image formats (`svg`, `pdf`, `swf`, `ai`, etc.) it would be a different story. – Matt Brock Feb 15 '12 at 04:10