Hi, I am trying fan coding and have a rather simple doubt. I have an instance of "Image". I've called resize on it to resize it.. Now how do I write it back to a file?
Also, Whenever I try to use ImageIO.read(File), using java FFI, it seems to hang, any clues on why this could happen?
thanks, Jerlin
brianMon 1 Mar 2010
Now how do I write it back to a file?
There are currently no encoders to write an image from memory back to a PNG or JPEG file.
Also, Whenever I try to use ImageIO.read(File), using java FFI, it seems to hang, any clues on why this could happen?
You can post a stack trace which might show what is going on. But I don't think Java's ImageIO can work with SWT anyhow.
jerlinTue 2 Mar 2010
Thanks brian. The bug I've is strange. I've code like this using java FFI to get an instance of BufferedImage
f := File(`/Users/jerlin/Documents/photoshop-images/creative.png`)
BufferedImage image := (BufferedImage) ImageIO.read(Interop.toJava(f.in));
echo("done")
Now if the same code is put in main and execute as a fan script, it works fine. However if the same code goes in doGet of wisp servlet, ImageIO.read() hangs indefenitely.. Do you know why this could happen?
Jerlin
brianTue 2 Mar 2010
Jerlin,
I tried your code in a weblet and didn't see any hang-up. If you can get a thread dump you can post that (or just email me). One thing you might want to make sure is that you don't have any code which might be kicking off the AWT event loop which would cause that thread to hang.
jerlinTue 2 Mar 2010
Here is trace of the thread that hangs.. Thanks for helping!
Name: ThreadPool-Worker-5 State: RUNNABLE Total blocked: 0 Total waited: 2
jerlin Mon 1 Mar 2010
Hi, I am trying fan coding and have a rather simple doubt. I have an instance of "Image". I've called resize on it to resize it.. Now how do I write it back to a file?
Also, Whenever I try to use ImageIO.read(File), using java FFI, it seems to hang, any clues on why this could happen?
thanks, Jerlin
brian Mon 1 Mar 2010
There are currently no encoders to write an image from memory back to a PNG or JPEG file.
You can post a stack trace which might show what is going on. But I don't think Java's ImageIO can work with SWT anyhow.
jerlin Tue 2 Mar 2010
Thanks brian. The bug I've is strange. I've code like this using java FFI to get an instance of BufferedImage
Now if the same code is put in main and execute as a fan script, it works fine. However if the same code goes in doGet of wisp servlet, ImageIO.read() hangs indefenitely.. Do you know why this could happen?
Jerlin
brian Tue 2 Mar 2010
Jerlin,
I tried your code in a weblet and didn't see any hang-up. If you can get a thread dump you can post that (or just email me). One thing you might want to make sure is that you don't have any code which might be kicking off the AWT event loop which would cause that thread to hang.
jerlin Tue 2 Mar 2010
Here is trace of the thread that hangs.. Thanks for helping!
Name: ThreadPool-Worker-5 State: RUNNABLE Total blocked: 0 Total waited: 2
Stack trace:
jerlin Tue 2 Mar 2010
Ok, I got this fixed by commenting the following lines in fanlaunch
Hope this helps someone facing the same problem in future.