Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / April 2006

Tip: Looking for answers? Try searching our database.

Creating Thumbnail Images on the fly

Thread view: 
cantbprince - 11 Apr 2006 15:31 GMT
Anyone know how to create thumbnail images on the fly?
Rhino - 11 Apr 2006 15:36 GMT
> Anyone know how to create thumbnail images on the fly?

Define "on the fly" in this context, i.e. explain how it's different from
creating thumbnails in some way that isn't "on the fly".

--
Rhino
cantbprince - 11 Apr 2006 15:59 GMT
Basically what i am trying to do is create a photo gallery on a jsp
page i have the following code (though very ugly).  Right now the image
is being downloaded in full by the user and just being resized to fit
the defined dimensions.  What i would like to do is have the page
create thumbnails as it finds each file and then display those (for
faster downloading)

CODE:
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%@ taglib prefix="sql" uri="http://java.sun.com/jstl/sql_rt" %>

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import = "java.io.File"%>
<jsp:include page="header.jsp"/>
<html>
   <h1 align="center">Photo Gallery</h1>

  <table WIDTH="930" ALIGN="CENTER" BORDER="1">

   <%
       String directory = "C:/site/photo/";

       File dataDir = new File(directory);

       File[] listing = dataDir.listFiles();
       String filename = "";

       for(int x = 0; x < listing.length; x++)
       {
            // out.println("<img" + " src=/photo//>");
           filename = listing[x].getName();
   %>
      <td align="center">
      <%
           out.println(" <img src=\"" +"photos/"+ filename +" \"" +
"width=\"95\" height=\"100\" />");
   %>

   <%

           out.println(filename);
       }
   %>
      </td>
  </table>
</html>
Oliver Wong - 11 Apr 2006 19:53 GMT
> Basically what i am trying to do is create a photo gallery on a jsp
> page i have the following code (though very ugly).  Right now the image
> is being downloaded in full by the user and just being resized to fit
> the defined dimensions.  What i would like to do is have the page
> create thumbnails as it finds each file and then display those (for
> faster downloading)

   Good thing you clarified your message, I thought you were talking about
a local J2SE application!

<pseudoCode>
URL getThumbnailFor(URL originalSizeImage) {
 check thumbnail cache to see if we've already made a thumbnail of this
image;
 if (already have thumbnail) {
   return URL to already made thumbnail.
 }
 load originalSizeImage;
 resize the image to thumbnail size;
 add thumbnail to cache;
 return URL to already made thumbnail.
}
</pseudoCode>

   - Oliver


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.