You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by hjw <hj...@gmail.com> on 2008/02/29 02:21:22 UTC

A problem about save image

Hi.

I try to write a programme ,which is used to download imagein some html.

I can get the page content ,and analyse the image url ,but when I download
and save the image using InputStream and ImageIO,there is a problem .It is
the size of image is not right,it seems the image was only a part of the
original,for example,the image in html is 600*800,it is the right size when
save as in IE, but downloaded in my programme,the size is 600*600 ,some data
is miss .I am sure it is not Internet problem.

Below is the code,the output is always N*N(600*600),could you tell me what
the problem is ?

InputStream in = get.getResponseBodyAsStream();
BufferedImage input = ImageIO.read(in);
ImageIcon icon = new ImageIcon(input);
System.out.println(icon.getIconHeight()+"*"+icon.getIconWidth());

Thanks and Regards,

Raymond

Re: A problem about save image

Posted by Roland Weber <os...@dubioso.net>.
Hello Raymond,

> I try to write a programme ,which is used to download imagein some html.
> 
> I can get the page content ,and analyse the image url ,but when I download
> and save the image using InputStream and ImageIO,there is a problem .It is
> the size of image is not right,it seems the image was only a part of the
> original,for example,the image in html is 600*800,it is the right size when
> save as in IE, but downloaded in my programme,the size is 600*600 ,some data
> is miss .I am sure it is not Internet problem.
> 
> Below is the code,the output is always N*N(600*600),could you tell me what
> the problem is ?
> 
> InputStream in = get.getResponseBodyAsStream();

Here is the point where the responsibility of the HttpComponents team ends.

> BufferedImage input = ImageIO.read(in);
> ImageIcon icon = new ImageIcon(input);
> System.out.println(icon.getIconHeight()+"*"+icon.getIconWidth());

We have no idea, nor do we care, what BufferedImage, ImageIO and ImageIcon
do to your data. Why don't you store the data from get.getResponseBodyAsStream
in a file and open that with an image viewer? If the contents of the file
is different from the result of a browser's "Save Image As..." then we can
help you figure out the differences. If it's not, you'll have to contact
people familiar with the XxxImageXxx classes.

cheers,
   Roland


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org