Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Convert image to byte[ ]  RSS feed

 
williams ilenikhena
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,

has any body done this recently, i'll be grateful if i get some tips.

i had my image in byte[],
then...

ImageIcon imgIcon = new ImageIcon(byteArray);
Image img = imgIcon.getImage();
img = img.getScaledInstance(imageWidth, imageHeight, Image.SCALE_AREA_AVERAGING);

//imageWidth is new width;
//imageHeight is new height;


my intention is to scale the image, take it back to byte[] so i can store the byte[] in my db.

Any tips....?
 
Joe Ess
Bartender
Posts: 9406
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have a look at javax.imageio.ImageIO
 
williams ilenikhena
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ImageIO doesn't have any methods that return a byte[]

if you'll be more specific pls...
 
Joe Ess
Bartender
Posts: 9406
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is such a thing as a ByteArrayOutputStream
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!