Re: sizing down an uploaded photo

Andy Engle <[email protected]>
Newsgroups gmane.comp.java.sun.servlet
Message-ID <[email protected]>
"Carter, Scott" <[email protected]> wrote:

> I am hoping that someone using servlets has encountered this problem.
> I have a web site where user's can upload photos, but after the
> servlet uploads the file I would like it to also resize the
> deminsions of the picture and the quality (size).  Has anyone run
> into this problem?

I have some experience with this, not with servlets, but with PHP.  I
am sure you can do some image resizing with servlets, but I haven't
tried that way yet.  Anyway, this is what I did: I grabbed some PHP
code that handles uploads of images, and then when I got the image
uploaded I gave it a temporary name (for example, "abc.jpg") and wrote
it to a temporary directory on the server, just as you can do with a
servlet.  Then, I made a system call to "convert", which is a part of
imagemagick, to do the resizing for me.  I specified the reduced
image's name to be abc_small.jpg, and then I read that image, the
smaller one, back into the PHP (or, servlet in your case).  From there
I shlep'd it into the database, indexed it, and it was ready to go.
Then you can do whatever cleanup necessary, such as removing the
temporary files, etc.

Like I said, there may be some slicker way of doing it all inside the
servlet, but in my experience with imagemagick I've found that it runs
pretty quickly and really does a great job with doing the resizing.
Let me know if you try this way with your servlet -- I'd like to hear
how it goes.


Andy

___________________________________________________________________________
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.