Creating Thumbnail Images on the fly

R

Rhino

cantbprince said:
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".
 
C

cantbprince

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>
 
O

Oliver Wong

cantbprince said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top