[Tutor] From byte[] to Image

Alan Gauld alan.gauld at freenet.co.uk
Sat Sep 16 23:29:27 CEST 2006


Hi Ziad,

Can you give us a bit mor4e detail.

> #**************************************************************
> # fileName is the path of the file
> stream = service.getFile(fileName)
> 
> file = open("pic.jpeg", 'w')
> 
> img = Image.frombuffer("1", (128, 128), stream)
> img.save(file)

Which library are you using here? Is it the PIL?

> The Java method is: "public byte[] getFile(String path)"
> 
> This is not working. I am not able to get all the data of the image
> and for sure not able to form the complete image.

Are you saying the Java code is not working?
Or that the value you get back from the web service is not 
what you expected? Or that the resultant byte array is what 
you expected but it is not being transformed to an image correctly?

I'm not 100% sure what the problem is here.

Alan G.


More information about the Tutor mailing list