The Library I am using is the PIL. And I read the Docs, they say the following about "frombuffer" operation:
(Note that this function decodes pixel data only, not entire images. If you have an entire image file in a string, wrap it in a StringIO object, and use open to load it.)
So I guess "frombuffer" must not be used in my case.
The java method is working correctly but I am not able to form the picture in the right way at the client side using the PIL library.
I am receiving an array of byte from "public byte[] getFile(String path)", but how to form the Image at the client side?
By the way that is how I am sending the Image as byte array to the python client:
public byte[] getFile(String fileName){
try{
File imgFile = new File(fileName);
BufferedImage img = ImageIO.read(imgFile);
ByteArrayOutputStream bas = new ByteArrayOutputStream();
ImageIO.write(img, "jpg", bas);
data = ""> } catch (Exception e){
e.printStackTrace();
}
System.out.println(data[2]);
return data;
} // end getFile
I receive it at the client side in python:
buffer = service.getFile(fileName)
How to form the Image from here? It is a jpg Image constructed originally from vtk using Mesa library for off-screen rendering.
Thank you again,
Ziad
On 9/16/06, Alan Gauld <[EMAIL PROTECTED]> wrote:
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.
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor