• Post Reply Bookmark Topic Watch Topic
  • New Topic

Fetching an image from the specified URL and resizing it.

 
Debasmita Dash
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I have to fetch an image from the given URL and resize it before displaying the same on the html page.
I am able to do this using java.awt.image.BufferedImage and javax.imageio.ImageIO APIs. But I need to do the same without using java.awt. I tried the following code but it's not working. The output file doesn't contain the image.


Thanks for your help.
 
Carey Brown
Bartender
Posts: 2257
28
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you mean "D:\\output.gif" ?

Also, read() is not guaranteed to read a full buffer's worth.
 
Paul Clapham
Sheriff
Posts: 21892
36
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And what is the purpose of writing to a ByteArrayOutputStream and then copying from that to a FileOutputStream? Why not just write directly to the FileOutputStream? (With the corrected code as per Carey Brown's comment, of course.)
 
Debasmita Dash
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Carey and Paul for replying.

I will be using the ByteArrayOutputStream further to display the image in html page and have used the FileOutputStream here to check the image content.

Thanks,
Debasmita
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!