I'm not using JAI exactly (rather the Java2D), but it looks similar. This
is what I have working:
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(OutputStream);
JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam(BufferedImage);
param.setQuality(0.75f, false);
encoder.setJPEGEncodeParam(param);
encoder.encode(temp);
Hope this helps. If not, you're in over my head...
Lance Lavandowska
http://www.AgDomain.Com
-----Original Message-----
From: Steve Meister <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
Date: Wednesday, September 29, 1999 8:23 AM
Subject: JAI in a Servlet problem
>Sorry about the cross post!
>
>Anyway, I have an applet that sends an Image to a Servlet. The Servlet is
>then supposed to save the Image out as a JPEG file. The applet to servlet
>transfer works fine. Here's a code snippet from the servlet:
>
> Image image; // obtained elsewhere
>
> FileOutputStream out = new FileOutputStream("c:\\image.jpg");
>
> ImageEncoder encoder =
> ImageCodec.createImageEncoder("JPEG", out, new JPEGEncodeParam());
> encoder.encode((BufferedImage) image);
>
> out.flush();
> out.close();
>
>(all of this is in a try block.)
>
>I'm getting a FileNotFoundException within the call to
>ImageCodec.createImageEncoder (verified by bracketing the call with
>println's). If I put an out.close() after the call to the
FileOutputStream
>constructor, the file gets created, so it's not a security issue.
>
>My configuration: Windows 98, Internet Explorer 5. Java Web Server 2.0.
I've
>set my PATH variable to include the JAI installation's "lib" directory,
and
>I've also copied the JAI .dll's and .jar's into the Java Web Server's
"lib"
>directory for good measure.
>
>The exception is actually reported in the Java Console window for the
>browser the applet is running in, but bracketing each statement in both
the
>applet and the servlet shows that the exception definitely occurring in
the
>call to ImageCodec.createImageEncoder.
>
>Any ideas? Thanks!
>
>_________________________________________________________________________
__
>To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
>of the message "signoff SERVLET-INTEREST".
>
>Archives: http://archives.java.sun.com/archives/servlet-interest.html
>Resources: http://java.sun.com/products/servlet/external-resources.html
>LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html