> > So if I have an applet that saves a picture...
> >
[quoted text clipped - 37 lines]
> If either of those options aren't what you are trying to do, just let us
> know.
> I want:
> -The applet to create a jpg in memory from either a BufferedImage,
> Image, or Graphics or whatever else.
Create a BufferedImage and draw on it.
> -The applet to upload the jpg to a program on my server maybe in a POST
> request
You can either do the HTTP connection with Sockets and Streams or use
the HTTPURLConnection class. Write the BufferedImage to your server
with the ImageIO.write() in JPEG format.
> -My program to process the jpg
I've never used PHP but I have processed form data with Perl. You
should be able to read the data and write it to a file with no problems
as it will already be in JPEG file format.
> I don't really know how to program servlets or JSP, so I just want my
> php script to handle the server side, and that's why I probably can't
> use a stream. Or maybe they're compatible somehow and I can do a
> stream...?
I don't either but I don't know why you couldn't use a stream.
> Also, it seems that every client needs a JPG java package if they want
> to use such an applet. Is this a fair assessment? If so, I am willing
> to look into other image file types.
I don't think so. JPEG is just a file format. The file is still an
array of bytes. If you send your server an array of bytes that is an
image of a JPEG file then you can just write the bytes to a file and
you're done.
Why don't you write your server in Java?

Signature
Knute Johnson
email s/nospam/knute/
Lee - 13 Jun 2006 18:59 GMT
I don't really know any java... this is kind of my first real program
in it. My whole site is in php though (which is definitely very
similar to perl although easier to use in my opinion). This is why it
would be great if I could get the image converted right away before it
reaches the server from the applet.
So what I'd like to know is:
-is it actually true that I would have to make clients download a jpg
java package if I wanted the applet to convert the BufferedImage?
-Do you or does anyone have a nice method that converts a BufferedImage
to jpg or other format?
-how exactly would I use the HTTPURLConnection class or ImageIO class
in that manner?
I am so new to Java that small details will be greatly appreciated.
Thanks!
> > I want:
> > -The applet to create a jpg in memory from either a BufferedImage,
[quoted text clipped - 32 lines]
>
> Why don't you write your server in Java?
Knute Johnson - 13 Jun 2006 23:26 GMT
> I don't really know any java... this is kind of my first real program
> in it. My whole site is in php though (which is definitely very
[quoted text clipped - 6 lines]
> -is it actually true that I would have to make clients download a jpg
> java package if I wanted the applet to convert the BufferedImage?
No. They will however have to have a modern version of the Java Runtime
Environment. Version 1.4 or later.
> -Do you or does anyone have a nice method that converts a BufferedImage
> to jpg or other format?
The ImageIO class has methods that will write a BufferedImage to a file
or stream in JPEG format.
> -how exactly would I use the HTTPURLConnection class or ImageIO class
> in that manner?
You need to look at the docs. I would download a copy but you can look
at them on the web here:
http://java.sun.com/j2se/1.5.0/docs/index.html
> I am so new to Java that small details will be greatly appreciated.
> Thanks!
This is a pretty sophisticated undertaking for not knowing much about
the language. You could write your client in C++ too. I think Java is
easier but that is just my opinion.
Is your Applet going to be some sort of drawing program or ? I would
start with that part first. Start writing your Applet and get it to the
point that you can create your JPEG image then worry about how to get it
to your server. Look at the docs.

Signature
Knute Johnson
email s/nospam/knute/
Lee - 14 Jun 2006 05:14 GMT
Amazingly, I have already created the drawing program at
lskatz.com/java, and I have a "save" button connected to a save method,
which I hope to take in a bufferedimage and upload a jpg to my server
in POST.
Would I use something similar to this function I found? I already have
a bufferedImage, so I can pick it up from there
public imageConvert() {
try {
BufferedImage b = ImageIO.read(new File("img1.gif"));
ImageIO.write(b,"JPEG",new File("img1.jpg"));
} catch (IOException e) {
System.out.println(e);
}
}
So I would just use ImageIO.write(b,"JPEG",new File(filename));
And then I will figure out the httpconnection thing.
> > I don't really know any java... this is kind of my first real program
> > in it. My whole site is in php though (which is definitely very
[quoted text clipped - 35 lines]
> point that you can create your JPEG image then worry about how to get it
> to your server. Look at the docs.
Oliver Wong - 14 Jun 2006 22:47 GMT
> Amazingly, I have already created the drawing program at
> lskatz.com/java
Rather than drawing a dot at the mouse location when the button is down,
how about drawing a line from the previous location to the current location,
so there's less of a "leaky, drippy pen" effect?
- Oliver
Lee - 14 Jun 2006 23:57 GMT
I might come up with other drawing tools on it later to add to the
current three that I have, but I'm leaving it basic for now. It's a
good idea.
> > Amazingly, I have already created the drawing program at
> > lskatz.com/java
[quoted text clipped - 4 lines]
>
> - Oliver