Help with creating thumbnail images

Hi there
I need some help with a webpage that displays images.
I am capturing an internal xml file ..and want to display:
An Image or images with a width of 130 px and height of 130
px
My problem is that when our users upload the pictures to the
website ..they are not resized ..and they would not know how to use
a program to do this.
Is there a code or way to take the uploaded picture file and
reduce it to a size of 130 x 130 in the existing page?
It currently is displaying the full size image(s) which are
take up 2 screens.
thanks for your time ..Rob

> Is there a code or way to take the uploaded picture file
and reduce it to
> a
> size of 130 x 130 in the existing page?
In the HTML you can just give it a width and height of those
values.
However, the full image is still loaded by the browser, so if
the image is
large, it's still going to be a bandwidth hog.
Ideally, you'd resize on the server at time of upload. This
can be done with
various components depending on the particular back-end
server/scripting
language.
-Darrel

Similar Messages

  • Create Thumbnail Image in JSP

    I have JSP a page, were I want to show Thumbnail Image from specified path. The specified path contain one or more file. If anybody have the code or reference for doing this please replay. (For one image will also the helpfule for me)
    Thank You

    The following is what I use to create thumbnail images. It uses struts, is a bit of a haste work but never failed in creating thousands of thumbnails. I'd be glad if you suggest improvement.
    import java.io.*;
    import java.text.*;
    import java.util.*;
    import org.apache.struts.upload.FormFile;
    import javax.imageio.ImageIO;
    import java.awt.*;
    import java.awt.image.BufferedImage;
    import org.apache.log4j.Logger;
    * @author Niklas
    public class ClassifiedImage {
        Logger log = Logger.getLogger(this.getClass());
        /** Creates a new instance of ClassifiedImage */
        public ClassifiedImage() {
        public void generateImage(FormFile file, String outputFilename, String outputthumbFilename) {
            try {
                String type = file.getContentType();
                String name = file.getFileName();
                int size = file.getFileSize();
                byte[] data = file.getFileData();
                if (data != null && name.length() > 0) {
                    ByteArrayInputStream bis = new ByteArrayInputStream(data);
                    BufferedImage bi = ImageIO.read(bis);
                    int width = bi.getWidth();
                    int height = bi.getHeight();
                    Image thumb = null;
                    if (width > 600 || height > 600) {
                        Image scaledimage = null;
                        if (width > 600) {
                            scaledimage = bi.getScaledInstance(600, -1, Image.SCALE_SMOOTH);
                            thumb = bi.getScaledInstance(80, -1, Image.SCALE_SMOOTH);
                            BufferedImage scaledBuffImage = StrutsUploadAction.toBufferedImage(scaledimage);
                            BufferedImage thumbBuffImage = StrutsUploadAction.toBufferedImage(thumb);
                            int newWidth = scaledBuffImage.getWidth();
                            int newHeight = scaledBuffImage.getHeight();
                            int thumbBuffImagenewWidth = thumbBuffImage.getWidth();
                            int thumbBuffImagenewHeight = thumbBuffImage.getHeight();
                            if (thumbBuffImagenewHeight > 60) {
                                thumb = thumbBuffImage.getScaledInstance(-1, 60, Image.SCALE_SMOOTH);
                            if (newHeight > 600) {
                                scaledimage = scaledBuffImage.getScaledInstance(-1, 600, Image.SCALE_SMOOTH);
                            BufferedImage scaledthumbBuffImage = StrutsUploadAction.toBufferedImage(thumb);
                            BufferedImage scaledBuffImage2 = StrutsUploadAction.toBufferedImage(scaledimage);
                            int newWidth2 = scaledBuffImage2.getWidth();
                            int scaledNewHeight = scaledBuffImage2.getHeight();
                            String formatName = "jpg"; // desired format
                            File outputFile = new File(outputFilename);
                            File outputthumbfile = new File(outputthumbFilename);
                            if (width > 600 || newHeight > 600) {
                                boolean writerExists = ImageIO.write(scaledBuffImage2, formatName, outputFile);
                                boolean writerthumbExists = ImageIO.write(scaledthumbBuffImage, formatName, outputthumbfile);
                        } else if (height > 600) {
                            Image scaledimage2 = bi.getScaledInstance(-1, 600, Image.SCALE_SMOOTH);
                            thumb = bi.getScaledInstance(-1, 60, Image.SCALE_SMOOTH);
                            BufferedImage scaledBuffImage2 = StrutsUploadAction.toBufferedImage(scaledimage2);
                            int newWidth2 = scaledBuffImage2.getWidth();
                            int newHeight2 = scaledBuffImage2.getHeight();
                            BufferedImage scaledthumbBuffImage2 = StrutsUploadAction.toBufferedImage(thumb);
                            int newthumbWidth2 = scaledthumbBuffImage2.getWidth();
                            int newthumbHeight2 = scaledthumbBuffImage2.getHeight();
                            if (newWidth2 > 600) {
                                scaledimage2 = scaledBuffImage2.getScaledInstance(600, -1, Image.SCALE_SMOOTH);
                            if (newthumbWidth2 > 80) {
                                thumb = scaledthumbBuffImage2.getScaledInstance(80, -1, Image.SCALE_SMOOTH);
                            BufferedImage ndscaledBuffImage2 = StrutsUploadAction.toBufferedImage(scaledimage2);
                            BufferedImage ndscaledthumbBuffImage2 = StrutsUploadAction.toBufferedImage(thumb);
                            int n_newWidth2 = ndscaledBuffImage2.getWidth();
                            int n_newHeight2 = ndscaledBuffImage2.getHeight();
                            String formatName2 = "jpg"; // desired format
                            File outputFile2 = new File(outputFilename);
                            File outputfile3 = new File(outputthumbFilename);
                            if (height > 600 || newHeight2 > 600) {
                                boolean writerExists2 = ImageIO.write(ndscaledBuffImage2, formatName2, outputFile2);
                                boolean writerExists3 = ImageIO.write(ndscaledthumbBuffImage2, formatName2, outputfile3);
                    } else {
                        FileOutputStream fileOut = new FileOutputStream(outputFilename);
                        fileOut.write(data);
                        fileOut.flush();
                        fileOut.close();
                        BufferedImage b = null;
                        ByteArrayInputStream bi2 = new ByteArrayInputStream(data);
                        BufferedImage bufi2 = ImageIO.read(bi2);
                        int width2 = bi.getWidth();
                        int height2 = bi.getHeight();
                        Image thumbnail2 = null;
                        if (height2 > width2) {
                            thumb = bufi2.getScaledInstance(-1, 60, Image.SCALE_SMOOTH);
                            BufferedImage scaledBuffImagethumb = StrutsUploadAction.toBufferedImage(thumb);
                            int newWidth7 = scaledBuffImagethumb.getWidth();
                            int newHeight7 = scaledBuffImagethumb.getHeight();
                            if (newWidth7 > 80) {
                                thumb = scaledBuffImagethumb.getScaledInstance(80, -1, Image.SCALE_SMOOTH);
                            b = StrutsUploadAction.toBufferedImage(thumb);
                        } else {
                            thumb = bufi2.getScaledInstance(80, -1, Image.SCALE_SMOOTH);
                            BufferedImage scaledthumb = StrutsUploadAction.toBufferedImage(thumb);
                            int scaledthumbwidth = scaledthumb.getWidth();
                            int scaledthumbheight = scaledthumb.getHeight();
                            if (scaledthumbheight > 60) {
                                thumb = scaledthumb.getScaledInstance(-1, 60, Image.SCALE_SMOOTH);
                            b = StrutsUploadAction.toBufferedImage(thumb);
                        File f = new File(outputthumbFilename);
                        boolean bo = ImageIO.write(b, "jpg", f);
            } catch (Exception e) {
                log.error(e.getMessage(), e);
    }And the helper method:
    // This method returns a buffered image with the contents of an image
        public static BufferedImage toBufferedImage(Image image) {
            if(image instanceof BufferedImage) {
                return (BufferedImage)image;
            // This code ensures that all the pixels in the image are loaded
            image = new ImageIcon(image).getImage();
            // Determine if the image has transparent pixels; for this method's
            // implementation, see e661 Determining If an Image Has Transparent Pixels
            boolean hasAlpha = false;
            // Create a buffered image with a format that's compatible with the screen
            BufferedImage bimage = null;
            GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
            try {
                // Determine the type of transparency of the new buffered image
                int transparency = Transparency.OPAQUE;
                if(hasAlpha) {
                    transparency = Transparency.BITMASK;
                // Create the buffered image
                GraphicsDevice gs = ge.getDefaultScreenDevice();
                GraphicsConfiguration gc = gs.getDefaultConfiguration();
                bimage = gc.createCompatibleImage(image.getWidth(null), image.getHeight(null), transparency);
            } catch(HeadlessException e) {
                // The system does not have a screen
            if(bimage == null) {
                // Create a buffered image using the default color model
                int type = BufferedImage.TYPE_INT_RGB;
                if(hasAlpha) {
                    type = BufferedImage.TYPE_INT_ARGB;
                bimage = new BufferedImage(image.getWidth(null), image.getHeight(null), type);
            // Copy image to buffered image
            Graphics g = bimage.createGraphics();
            // Paint the image onto the buffered image
            g.drawImage(image, 0, 0, null);
            g.dispose();
            return bimage;
        }

  • I need help with creating PDF with Preview...

    Hello
    I need help with creating PDF documetns with Preview. Just a few days ago, I was able to create PDF files composed of scanned images (notes) and everything worked perfectly fine. However, today I was having trouble with it. I scanned my notebook and saved 8 images/pages in jpeg format. I did the usual routine with Preview (select all files>print>PDF>save as PDF>then save). Well this worked a few days ago, but when I tried it today, I was able to save it, but the after opening the PDF file that I have saved, only the first page was there. The other pages weren't included. I really don't see anything wrong with what I'm doing. I really need help. Any help would be greatly appreciated.

    I can't find it.  I went into advanced and then document processing but no batch sequence is there and everything is grayed out.
    EDIT: I realized that you cant do batch sequences in standard.  Any other ideas?

  • Trying to add album from iphoto into idvd slideshow.  Not all photos are loading.  Message "creating thumbnail images...(31 remaining).  Been there a long time.  What is wrong?

    trying to add album from iphoto into idvd slideshow.  Not all photos are loading.  Message "creating thumbnail images...(31 remaining).  Been there a long time.  What is wrong?

    Open your iPhoto Library, go to that particular album and verify that you can view the full sized version of each image by double clicking on them.  Report back with the results.
    OT

  • IDVD won't create thumbnail images in slide shows

    In a slide show, the window that used to show the photos in a slide show no longer renders thumbnails in the list or grid views. The status at the top of the window just sits there and spins forever, with the text "Creating thumbnail images...." Anyone know of a workaround?

    Neither of these "fixes" has changed anything. I also cleared my cache, ran a diagnostic check, and a virus/trojan scan! Either way, firefox 4 is just not working up to my needs! Should, or can I go back to 3.6?

  • Import Images into slide show - Creating Thumbnail images -Hang

    I am using iDVD 7. I imported my images into a slideshow. The pictures were not in iPhoto but just a folder that I created and edited in Photoshop. Once I import the images, the window shows all the file names as expected but all the Image Thumbnails are blank and the top of the window there is a message "+Creating thumbnail images... (32 remaining)+" with a spinning wheel next to the message. This message stays there forever. The 32 is the number of images in the slideshow. I can do most things in iDVD while this is going on, but I cannot add the audio I want.
    What is causing this and can I get it to stop?

    To add to this I decided to remove the slideshow and now import the pictures from iPhoto. I can only get ride of the message by closing iDVD down. When I relaunch iDVD the message is gone. When I now import the pictures from iPhoto the same thing happens where it hangs on creating thumbnail images.

  • Create Thumbnail Image in KM

    Hello Everybody,
    I can upload images to KM Folders. But I want to create thumbnail image while i am uploading original image. I found one library but i cant call the create function from "com.sapportals.wcm.repository.manager.thumbnail.ResourceImageThumbnailPlugIn" library.
    Does anyone know how can i call this function from webdynpro?
    Kind Regards.
    Rasim

    Hello,
    You are right john. But i am using KM api library from webdynpro. I dont use km upload tool. for that reason it cant create thumbnail automatically. I need one library for creating thumbnails.
    Thanks satish for your link. But i dont understand what should i do with this link. My problem is if i uploaded jpg images, it cant created thumbnails automatically..

  • I need help with Creating Key Pairs

    Hello,
    I need help with Creating Key Pairs, I generate key pais with aba provider, but the keys generated are not base 64.
    the class is :
    import java.io.*;
    import java.math.BigInteger;
    import java.security.*;
    import java.security.spec.*;
    import java.security.interfaces.*;
    import javax.crypto.*;
    import javax.crypto.spec.*;
    import au.net.aba.crypto.provider.ABAProvider;
    class CreateKeyPairs {
    private static KeyPair keyPair;
    private static KeyPairGenerator pairGenerator;
    private static PrivateKey privateKey;
    private static PublicKey publicKey;
    public static void main(String[] args) throws Exception {
    if (args.length != 2) {
    System.out.println("Usage: java CreateKeyParis public_key_file_name privete_key_file_name");
    return;
    createKeys();
    saveKey(args[0],publicKey);
    saveKey(args[1],privateKey);
    private static void createKeys() throws Exception {
    Security.addProvider(new ABAProvider());
    pairGenerator = KeyPairGenerator.getInstance("RSA","ABA");
    pairGenerator.initialize(1024, new SecureRandom());
    keyPair = pairGenerator.generateKeyPair();
    privateKey = keyPair.getPrivate();
    publicKey = keyPair.getPublic();
    private synchronized static void saveKey(String filename,PrivateKey key) throws Exception {
    ObjectOutputStream out= new ObjectOutputStream(new FileOutputStream(filename));
    out.writeObject(key);
    out.close();
    private synchronized static void saveKey(String filename,PublicKey key) throws Exception {
    ObjectOutputStream out= new ObjectOutputStream( new FileOutputStream(filename));
    out.writeObject(key);
    out.close();
    the public key is:
    �� sr com.sun.rsajca.JSA_RSAPublicKeyrC��� xr com.sun.rsajca.JS_PublicKey~5< ~��% L thePublicKeyt Lcom/sun/rsasign/p;xpsr com.sun.rsasign.anm����9�[ [ at [B[ bq ~ xr com.sun.rsasign.p��(!g�� L at Ljava/lang/String;[ bt [Ljava/lang/String;xr com.sun.rsasign.c�"dyU�|  xpt Javaur [Ljava.lang.String;��V��{G  xp   q ~ ur [B���T�  xp   ��ccR}o���[!#I����lo������
    ����^"`8�|���Z>������&
    d ����"B��
    ^5���a����jw9�����D���D�)�*3/h��7�|��I�d�$�4f�8_�|���yuq ~
    How i can generated the key pairs in base 64 or binary????
    Thanxs for help me
    Luis Navarro Nu�ez
    Santiago.
    Chile.
    South America.

    I don't use ABA but BouncyCastle
    this could help you :
    try
    java.security.Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
    java.security.KeyPairGenerator kg = java.security.KeyPairGenerator.getInstance("RSA","BC");
    java.security.KeyPair kp = kg.generateKeyPair();
    java.security.Key pub = kp.getPublic();
    java.security.Key pri = kp.getPrivate();
    System.out.println("pub: " + pub);
    System.out.println("pri: " + pri);
    byte[] pub_e = pub.getEncoded();
    byte[] pri_e = pri.getEncoded();
    java.io.PrintWriter o;
    java.io.DataInputStream i;
    java.io.File f;
    o = new java.io.PrintWriter(new java.io.FileOutputStream("d:/pub64"));
    o.println(new sun.misc.BASE64Encoder().encode(pub_e));
    o.close();
    o = new java.io.PrintWriter(new java.io.FileOutputStream("d:/pri64"));
    o.println(new sun.misc.BASE64Encoder().encode(pri_e));
    o.close();
    java.io.BufferedReader br = new java.io.BufferedReader(new java.io.FileReader("d:/pub64"));
    StringBuffer keyBase64 = new StringBuffer();
    String line = br.readLine ();
    while(line != null)
    keyBase64.append (line);
    line = br.readLine ();
    byte [] pubBytes = new sun.misc.BASE64Decoder().decodeBuffer(keyBase64.toString ());
    br = new java.io.BufferedReader(new java.io.FileReader("d:/pri64"));
    keyBase64 = new StringBuffer();
    line = br.readLine ();
    while(line != null)
    keyBase64.append (line);
    line = br.readLine ();
    byte [] priBytes = new sun.misc.BASE64Decoder().decodeBuffer(keyBase64.toString ());
    java.security.KeyFactory kf = java.security.KeyFactory.getInstance("RSA","BC");
    java.security.Key pubKey = kf.generatePublic(new java.security.spec.X509EncodedKeySpec(pubBytes));
    System.out.println("pub: " + pubKey);
    java.security.Key priKey = kf.generatePrivate(new java.security.spec.PKCS8EncodedKeySpec(priBytes));
    System.out.println("pri: " + priKey);
    catch(Exception e)
    e.printStackTrace ();
    }

  • Help with creating a form, I want to add a check box to enable me to unlock certain fields and deselect the block again

    Help with creating a form, I want to add a check box to enable me to unlock certain fields and deselect the block again

    Look to the right under "More Like This". Your issue has been discussed many many times. The error you are seeing is because you do not have enough free "contiguous" space on your hard drive. Read the other threads that address this issue to find how to solve the issue.
    Or, put "The disk cannot be partitioned because some files cannot be moved" into the search box at the upper right of this page.

  • Help with creating a Quiz

    Hey i need help with creating a quiz with scoring and all.
    I need a helping hand so if you can get me started that
    would help a lot.
    Use the Question class to define a Quiz class. A
    quiz can be composed of up to 25 questions. Define the add method
    of the Quiz class to add a question to a quiz. Define the giveQuiz
    method of the Quiz class to present each question in turn to the user,
    accept an answer for each one, and keep track of the results. Define
    a class called QuizTime with a main method that populates a quiz,
    presents it, and prints the final results.
    // Question.java Author: Lewis/Loftus/Cocking
    // Represents a question (and its answer).
    public class Question implements Complexity
    private String question, answer;
    private int complexityLevel;
    // Sets up the question with a default complexity.
    public Question (String query, String result)
    question = query;
    answer = result;
    complexityLevel = 1;
    // Sets the complexity level for this question.
    public void setComplexity (int level)
    complexityLevel = level;
    // Returns the complexity level for this question.
    public int getComplexity()
    return complexityLevel;
    // Returns the question.
    public String getQuestion()
    return question;
    // Returns the answer to this question.
    public String getAnswer()
    return answer;
    // Returns true if the candidate answer matches the answer.
    public boolean answerCorrect (String candidateAnswer)
    return answer.equals(candidateAnswer);
    // Returns this question (and its answer) as a string.
    public String toString()
    return question + "\n" + answer;
    }

    Do you know why this lazy f&#97;rt-&#97;ss is back? Because when he posted his homework last week, some sorry-assed idiot went and did it for him.
    http://forum.java.sun.com/thread.jspa?threadID=5244564&messageID=10008358#10008358
    He didn't even thank the poster.
    It's the same problem over and over again. You feed the bears and it only teaches them to come back for handouts.
    My polite suggestion to the original poster: please do your own f&#117;cking homework.

  • Need help with creating a brush

    Hi guys,
    I wanted to ask for help with creating a brush (even a link to a tutorial will be goon enough ).
    I got this sample:
    I've created a brush from it, and i'm trying to get this kind of result:
    but it's only duplicates it and gives me this result:
    Can someone help me please understand what i need to define in order to make the brush behave like a continues brush instead of duplicate it?
    Thank you very much
    shlomit

    what you need to do is make a brush that looks like the tip of a brush. photoshop has several already but you can make your own that will be better.
    get a paintbrush and paint a spot kind of like what you did but dont paint a stroke. make it look kindof grungy. then make your brush from that, making sure to desaturate it and everything.
    EDIT:
    oh, and if you bring the fill down to like 10-20% your stroke will look better

  • Create Thumbnail Images

    Hello, I currently use Automator on Mac OS 10.4 Tiger. I most often use this program to create thumbnail images for easy web upload. However, I plan to upgrade my operating system to Leopard soon, and I was wondering, will my Automator workflows that I've created in Tiger work on the Leopard OS? If not, is their an equivalent automation on Leopard that will output thumbnail images?

    without knowing specifics it's hard to say anything definite but leopard automator includes everything Tiger automator had and a whole lot more. the action to create thumbnails is certainly present. you might have to remake the workflow from scratch but it will certainly work.

  • Creating Thumbnail Images

    Anyone know how to create thumbnail images on the fly?

    First google:
    http://www.google.co.uk/search?hl=en&q=java+create+thumbnail&btnG=Google+Search&meta=
    Then pick the first link:
    http://schmidt.devlib.org/java/save-jpeg-thumbnail.html

  • I need help with creating some formulas

    I'm not sure if anyone around here can help me, but I'm trying to create a Numbers document and need some help with creating a formula/function.
    I have a column of amounts and I would like to create a formula which deducts a percentage (11.9%) and puts the result in another column.
    If anyone can help me, it would be greatly appreciated.

    Here is an example that shows one way to do this:
    The original data is in column A.  In column B we will store formulas to adjust the amounts:
    1) select the cell where you want to formula (in this case cell B2)
    2) Type the "=" (equal sign):
    3) click cell A2:
    4) now type the rest of the formula which is: "*(100-11.9)/100"  that is asterisk, then open parenthesis, 100 minus eleven point nine close parenthesis forward slash  one hundred
    The Asterisk is the multiply operator  (times) and the forward slash is the division operator (divide)
    now hit return.  select cell B2 and hover the cursor over the bottom edge of the cell:
    drag the little yellow dot down to "fill" the formula down as needed.

  • OS X Mail High CPU "Creating Thumbnail Images"

    I just upgraded to Yosemite and noticed that my computer has become quite sluggish. I noticed that Mail is running the CPU very high. I opened the Activity window in mail and notice that it's continually "Creating Thumbnail Images". Does anyone know what exactly it's doing? Is there any way to limit the amount of CPU it uses?

    Hi, I have got some aditional information. I switched off all network connections and was able to remove the email from the outbox. Now I can use Mail again to fetch mail. To my surprise, the email that still resided in the outbox was sent. It was just not removed from the outbox.
    I rebuilt all mailboxes, still no change, i. e. same crash when trying to send an email.
    Any ideas?

Maybe you are looking for

  • How to change the auto generated thumbnail images for a clip?

    When iMovie created all the thumbnails for my clips it got most of them right, but on some of them it has choosen a frame that doens't really represent that clip. Is there any way to change the poster frame for each clip?

  • PC froze then died

     My PC had been working fine for several hours till I tried to sort out a problem with a silent front speaker. The front right speaker (5.1 system) sometimes stops working but can usually be fixed by repositioning or reinserting the plug in the onboa

  • Latest update, now does not show  apps are open

    I used to have a little arrow against the apps that were open. now Mail and Firefox are open but cannot tell that from the dock. Skype and Finder are the only ones, and they open on startup. Anyone know how to fix it? Thanks

  • Status associated with WBS element

    Hi, How can we get status associated with WBS element. thanks

  • Uninstall RemoteAccess with cmd?

    Hi, I am using Windows Server 2012 and have installed the remote-access (DirectAcces and VPN) role for my server, but without DHCP. So I am not getting an IP from my server and I can't connect anymore over my normal rdp connection. Now I only can rea