Creating thumbnail images and storing it as gif or jpg

Hi all,
Iam new to this forum. I need a solution for the problem iam facing in building my site. I have groups and briefcase section in my site. I allow users to upload files and pictures.
When they upload pictures i need to create thumbnail for them and store them as gif or jpeg.
It would be very greatful if i can get an early answer.
Please let me know if there is any other forum where i can get better answer, if not here?
thnx

I found the following searching through the forum, under jpeg or thumbnail, a while back -- maybe you can use it:
import java.awt.Image;
import java.awt.Graphics2D;
import java.awt.geom.AffineTransform;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.OutputStream;
import java.io.FileOutputStream;
import javax.swing.ImageIcon;
import com.sun.image.codec.jpeg.JPEGCodec;
import com.sun.image.codec.jpeg.JPEGImageEncoder;
class Thumbnail {
public static void main(String[] args) {
createThumbnail(args[0], args[1], Integer.parseInt(args[2]));
* Reads an image in a file and creates a thumbnail in another file.
* @param orig The name of image file.
* @param thumb The name of thumbnail file. Will be created if necessary.
* @param maxDim The width and height of the thumbnail must
* be maxDim pixels or less.
public static void createThumbnail(String orig, String thumb, int maxDim) {
try {
// Get the image from a file.
Image inImage = new ImageIcon(orig).getImage();
// Determine the scale.
double scale = (double)maxDim/(double)inImage.getHeight(null);
if (inImage.getWidth(null) > inImage.getHeight(null)) {
scale = (double)maxDim/(double)inImage.getWidth(null);
// Determine size of new image. One of them
// should equal maxDim.
int scaledW = (int)(scale*inImage.getWidth(null));
int scaledH = (int)(scale*inImage.getHeight(null));
// Create an image buffer in which to paint on.
BufferedImage outImage = new BufferedImage(scaledW, scaledH,
BufferedImage.TYPE_INT_RGB);
// Set the scale.
AffineTransform tx = new AffineTransform();
// If the image is smaller than the desired image size,
// don't bother scaling.
if (scale < 1.0d) {
tx.scale(scale, scale);
// Paint image.
Graphics2D g2d = outImage.createGraphics();
g2d.drawImage(inImage, tx, null);
g2d.dispose();
// JPEG-encode the image and write to file.
OutputStream os = new FileOutputStream(thumb);
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(os);
encoder.encode(outImage);
os.close();
} catch (IOException e) {
e.printStackTrace();
System.exit(0);
V.V.

Similar Messages

  • 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.

  • 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 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;
        }

  • 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?

  • Created searchBean map and stored on session fail!

    Hi :
    I met a problem while entering a jsp page , seems like its "Created searchBean map and stored on session" was missing , and not every time I can produce this error , it happened dynamically.
    Any idea about this ?
    =======================================================
    if the jsp page run success , it will be produce debug log like these:
    Storing JhsAuthorizationProxy object on session to allow EL access to request.isUserInRole() and/or
    JhsUser.hasAccess()
    19:09:06 DEBUG (JhsActionServlet) -Request class: com.evermind.server.http.AJPHttpServletRequest
    19:09:06 DEBUG (JhsActionServlet) -Request URI: /BIL/StartBIL3060MBaseGroup.do
    19:09:06 DEBUG (JhsActionServlet) -Request Character Encoding: ISO-8859-1
    19:09:06 DEBUG (JhsActionServlet) -Parameter ArgUser: 0438
    19:09:06 DEBUG (JhsActionServlet) -Request class: com.evermind.server.http.AJPHttpServletRequest
    19:09:06 DEBUG (JhsActionServlet) -Request URI: /BIL/BIL3060MBaseGroup.do
    19:09:06 DEBUG (JhsActionServlet) -Request Character Encoding: ISO-8859-1
    19:09:06 DEBUG (JhsActionServlet) -Parameter ArgUser: 0438
    19:09:07 DEBUG (JhsDataAction) -Executing action /BIL3060MBaseGroup
    19:09:07 DEBUG (JhsDataAction) -Created searchBean map and stored on session
    19:09:07 DEBUG (JhsDataAction) -Created new searchBean for BIL3060MBaseGroupUIModel and added to quick search bean map
    19:09:07 DEBUG (JhsDataAction) -Stored searchBean for BIL3060MBaseGroupUIModel on request
    19:09:07 DEBUG (JhsDataAction) -Setting findMode to true for iterator binding BIL3060MBaseGroupIterator
    19:09:07 DEBUG (JhsDataAction) -Setting max fetch size -1 temporarily to 0 for ViewObject BIL3060MBaseView1
    19:09:07 DEBUG (JhsDataAction) -ViewObject BilPAID_FLAGView1: value of bind param 0 set to PAID_FLAG
    19:09:07 DEBUG (JhsDataAction) -
    ========================================================
    and if the jsp page failure, the debug log will be like folling content:
    07/09/20 19:07:42 0422crhin-jrung
    07/09/20 19:07:53 0433crhin-jrung
    07/09/20 19:07:53 [B@f55759
    07/09/20 19:07:53 [B@6fd560
    07/09/20 19:07:53 userPwd1:s_user_name:Johnson
    07/09/20 19:07:53 null
    19:07:53 DEBUG (JhsActionServlet) -Storing JhsAuthorizationProxy object on session to allow EL access to request.isUserInRole() and/or
      JhsUser.hasAccess()
    19:07:53 DEBUG (JhsActionServlet) -Request class: com.evermind.server.http.AJPHttpServletRequest
    19:07:53 DEBUG (JhsActionServlet) -Request URI: /BIL/StartBIL3060MBaseGroup.do
    19:07:53 DEBUG (JhsActionServlet) -Request Character Encoding: Big5
    19:07:53 DEBUG (JhsActionServlet) -Parameter ArgUser: 0422
    19:07:53 DEBUG (JhsActionServlet) -Request class: com.evermind.server.http.AJPHttpServletRequest
    19:07:53 DEBUG (JhsActionServlet) -Request URI: /BIL/BIL3060MBaseGroup.do
    19:07:53 DEBUG (JhsActionServlet) -Request Character Encoding: Big5
    19:07:53 DEBUG (JhsActionServlet) -Parameter ArgUser: 0438
    19:07:53 DEBUG (JhsDataAction) -Executing action /BIL3060MBaseGroup
    [b] 07/09/20 19:07:53 java.lang.NullPointerException
    07/09/20 19:07:53 at oracle.jheadstart.util.BindingUtils.findIterBinding(BindingUtils.java:116)
    07/09/20 19:07:53 at oracle.jheadstart.controller.strutsadf.action.JhsDataAction.applyIterBindParams(JhsDataAction.java:3450)
    07/09/20 19:07:53 at oracle.jheadstart.controller.strutsadf.action.JhsDataAction.prepareModel(JhsDataAction.java:3875)
    07/09/20 19:07:53 at oracle.adf.controller.struts.actions.DataAction.prepareModel(DataAction.java:486)
    07/09/20 19:07:53 at oracle.adf.controller.lifecycle.PageLifecycle.handleLifecycle(PageLifecycle.java:105)
    07/09/20 19:07:53 at oracle.adf.controller.struts.actions.DataAction.handleLifecycle(DataAction.java:222)
    07/09/20 19:07:53 at oracle.jheadstart.controller.strutsadf.action.JhsDataAction.handleLifecycle(JhsDataAction.java:506)
    07/09/20 19:07:53 at oracle.adf.controller.struts.actions.DataAction.execute(DataAction.java:153)
    07/09/20 19:07:53 at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
    07/09/20 19:07:53 at oracle.jheadstart.controller.strutsadf.JhsRequestProcessor.processActionPerform(JhsRequestProcessor.java:118)
    07/09/20 19:07:53 at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
    07/09/20 19:07:53 at oracle.jheadstart.controller.strutsadf.JhsRequestProcessor.process(JhsRequestProcessor.java:385)
    07/09/20 19:07:53 at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
    07/09/20 19:07:53 at oracle.jheadstart.controller.strutsadf.JhsActionServlet.process(JhsActionServlet.java:130)
    07/09/20 19:07:53 at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
    07/09/20 19:07:53 at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
    07/09/20 19:07:53 at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    07/09/20 19:07:53 at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:824)
    07/09/20 19:07:53 at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:330)
    07/09/20 19:07:53 at com.evermind.server.http.ServletRequestDispatcher.forward(ServletRequestDispatcher.java:222)
    07/09/20 19:07:53 at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1069)
    07/09/20 19:07:53 at org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProcessor.java:274)
    07/09/20 19:07:53 at org.apache.struts.action.RequestProcessor.internalModuleRelativeForward(RequestProcessor.java:1012)
    07/09/20 19:07:53 at org.apache.struts.tiles.TilesRequestProcessor.internalModuleRelativeForward(TilesRequestProcessor.java:345)
    07/09/20 19:07:53 at org.apache.struts.action.RequestProcessor.processForward(RequestProcessor.java:582)
    07/09/20 19:07:53 at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:260)
    07/09/20 19:07:53 at oracle.jheadstart.controller.strutsadf.JhsRequestProcessor.process(JhsRequestProcessor.java:385)
    07/09/20 19:07:53 at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
    07/09/20 19:07:53 at oracle.jheadstart.controller.strutsadf.JhsActionServlet.process(JhsActionServlet.java:130)
    07/09/20 19:07:53 at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
    07/09/20 19:07:53 at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
    07/09/20 19:07:53 at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    07/09/20 19:07:53 at com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:65)
    07/09/20 19:07:53 at oracle.jheadstart.controller.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:176)
    07/09/20 19:07:53 at com.evermind.server.http.EvermindFilterChain.doFilter(EvermindFilterChain.java:16)
    07/09/20 19:07:53 at oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:239)
    07/09/20 19:07:53 at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:659)
    07/09/20 19:07:53 at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:330)
    07/09/20 19:07:53 at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:830)
    07/09/20 19:07:53 at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:224)
    07/09/20 19:07:53 at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:133)
    07/09/20 19:07:53 at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:192)
    07/09/20 19:07:53 at java.lang.Thread.run(Thread.java:534)
    19:07:53 DEBUG (JhsDataAction) -Executing findForward
    19:07:53 DEBUG (JhsDataAction) -Forward set by parameter property
    19:07:53 DEBUG (JhsDataAction) -Forwarding to: /WEB-INF/page/BIL3060MBaseGroup.jsp
    19:07:53 WARN (RequestProcessor) -Unhandled Exception thrown: class java.lang.NullPointerException

    Eron,
    It looks like there is something wrong with the runtime representation of the pagedef that is not passed to ADF correctly.
    It could be a JDeveloper/ADF issue that is not related to JHeadstart. To simplify the test case, you could create a simple drag-and-drop ADF application without JHeadstart and see if the same problem occurs there. If so, can you please log a TAR at MetaLink ( http://metalink.oracle.com/ ), or ask this question at the JDeveloper forum at http://otn.oracle.com/discussionforums/jdev.html ?
    Thanks,
    Sandra Muller
    JHeadstart Team
    Oracle Consulting

  • 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

  • Create XML stream and stored as an output XML file

    Dear ALL,
    Could you help me in such situation?
    I need create XML file. I have DTD file. I create XML stream and stored as an output XML file. But all the data of my XML file stored in one line.
    How I can create my XML file according to DTD file?
    Thanks a lot.
    Best regards,
    Igor

    hi
    good
    go through this links,hope these would help you to solve your problem
    http://rustemsoft.com/JSPsample.htm
    http://publib.boulder.ibm.com/infocenter/wsphelp/index.jsp?topic=/com.ibm.etools.xmlbuilder.doc/tasks/txmltask.htm
    thanks
    mrutyun^

  • Trying to create an image and save it on file system

    Hi,
    I'm trying to create an image and save it in the file system :
         public static void main(String[] args) {
         int wid = 632;
         int hgt = 864;
         BufferedImage bufferedImage = new BufferedImage(wid,hgt,BufferedImage.TYPE_INT_RGB);
         bufferedImage.getGraphics().setColor(Color.black);
         bufferedImage.getGraphics().drawOval(30, 30, 100, 100);
              bufferedImage.getGraphics().drawString("test me one two three",2,2);
              bufferedImage.flush();
    try {
                   ImageIO.write(bufferedImage,".bmp",new File("C:/MyImage.bmp"));
         } catch (IOException e) {               
                   e.printStackTrace();
    THE PROBLEM : It creates C:/MyImage.bmp on my file system, but the file is empty (size 0).
    Am I missing something ?
    Thanks

    Try changing ".bmp" to "bmp". If that fails, try posting an SSCCE.
    Edit 1:
    And in future, please use the code tags when posting code, code snippets, HTML/XML or input/output. To do that, select the code and click the CODE button seen on the Plain Text tab of the message posting form.
    Edited by: AndrewThompson64 on Aug 3, 2009 1:23 AM

  • 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..

  • How to create thumbnail images on the fly from JSP or servlet?

    Hi all,
    Iam new to this forum. I need a solution for the problem iam facing in building my site. Ihave groups and briefcase section in my site. I allow users to upload files and pictures.
    When they upload pictures i need to create thumbnail for them on the fly.
    Is there any taglibs or java source to do this from JSP or servlets.
    It would be very greatful if i can get an early answer.
    Please let me know if there is any other forum where i can get better answer, if not here?
    thnx.

    Here is how you can create dynamic images:
    http://developer.java.sun.com/developer/JDCTechTips/2001/tt0821.html#tip2
    However, if you want to create gifs/jpegs and save them to the disk it depends from where you want to create the images. It is different if you are creating from another image or just drawing one from scratch etc.. But in the end you will probably need to use one of the imageencoder classes and write the result to the disk with the file io classes.

  • Accessing or creating thumbnail images of pages to use in navigation

    In Bridge I can scroll through the Indesign pages by scrolling through the thumbnail images without opening the Indesign file.
    Is it possible to access those thumbnails so that I can use them as page navigation buttons in the Indesign file, or is there another way to create a thumbnail of the pages to reuse as buttons?
    thanks

    In the thread here I mention an external utility I wrote to extract the JPEG thumbnails that InDesign creates for use in Bridge. If you don't use Windows, google a bit to find a Javascript that does the same. (The difference is, you need to run the JS from within InDesign; my program works without.)
    Both the script and the program can only extract what's in the file: http://help.adobe.com/en_US/indesign/cs/using/WSa285fff53dea4f8617383751001ea8cb3f-6d51a.h tml
    (Similar to the above, a PDF may contain a per-page thumbnail, but I have no idea on how to extract those.)

  • Class casting, creating an image and decompiling...

    Hi, I've got a couple of questions:
    1)
    How can I fully decompile classes, so with the implementation of the methods? Is it always possible to fully decompile a class file? When is it and when not?
    2)
    I aks this questions before, but I still haven't got it working, so sorry, but I ask it again :) :
    I want to create my own class, for example cMyClass which extends the java.awt.Image class, which has abstract methods. How do these methods(for example getGraphics etc) have to be implemented?
    3)
    I can't cast a Image to cMyClass... why not?
    Someone told me he did the following:
    Canvas c = new Canvas()
    cMyClass oImage = (cMyClass) c.createImage (100, 100);
    and that this worked... I tried to do this too, and it seemed to work, but it actually didn't!!
    I found out that c.createImage returns a null reference!!! That's why Java was able to cast it to my own cMyClass (not a problem to cast a null to something else), but when I created a Image (by doing a lot of unnessacary difficult stuff), and then tried to cast this Image to cMyClass it throw a ClassCastException or something like that...
    How can I cast the java.awt.Image class to my class anyway?
    3)
    Why can't you create a image like i've done above or even like below:
    Canvas c = new Canvas()
    Image oImage = c.createImage (100, 100);
    Why does this return a null reference?
    Isn't there a better way to create an image?
    4)
    The getWidth and getHeight need a I thought observer...? Why is this? I just want the width and height and don't have an observer or something like that. Is there a way around this?
    I tried getWidth(null) but this returns -1
    Please help! :)

    Hi, I've got a couple of questions:
    1)
    How can I fully decompile classes, so with the
    implementation of the methods? Is it always possible
    to fully decompile a class file? When is it and when
    not?You can always get a dump of the bytecode with 'javap -c'. If you don't want to figure things out yourself, try searching google for a class file decompiler, possibly a de-obfuscator.
    De-compilation is completely possible if the original author wanted that, by including debugging information. Depending on the degree of such information and the amount of code obfuscation, the decompiled code may lack variable names, line numbers, field and method names, class names, and even code structure. Names and line numbers are usually not re-creatable automatically, since the information is simply lost, but you can replace them with your own strings when analyzing an unknown class file (using the correct tools). Re-creating the original code structure may work in some cases, but to me the general case looks rather close to the halt problem (i.e. not solvable).
    Use a de-obfuscator, hope you've got good luck, and analyze the bytecode manually if that doesn't work.
    2)
    I aks this questions before, but I still haven't got
    it working, so sorry, but I ask it again :) :
    I want to create my own class, for example cMyClass
    which extends the java.awt.Image class, which has
    abstract methods. How do these methods(for example
    getGraphics etc) have to be implemented?I don't really understand the problem. 'abstract' means on the language level that your subclass must provide an implementation, i.e. a method body. What that method is expected to do is explained in the javadocs for Image. But in fact you're free to do anything. You could play a sound in the getWidth() method (replace with any method name if you want). Just consider the fact that a lot of code calls getWidth in the hope of getting the width of the image, not playing a sound. So much about the language level.
    On a higher level, a subclass of Image should implement a certain way to describe an image. AFAIK this means that your code must know the size of the image and know how to produce the pixels of the image. I can't tell you in general how you must do this, because it depends on your special case. This boils down to the question, why do you want to write a subclass of 'Image'? What new way of describing and image have you come up with?
    3)
    I can't cast a Image to cMyClass... why not?Simple, and that's certainly not an ALT. Because that specific Image is not a cMyClass. It's probably a BufferedImage or similar that was produced by AWT.
    Please read the specs carefully what casting is about.
    Someone told me he did the following:
    Canvas c = new Canvas()
    cMyClass oImage = (cMyClass) c.createImage (100,
    100);
    and that this worked... I tried to do this too, and it
    seemed to work, but it actually didn't!!
    I found out that c.createImage returns a null
    reference!!! That's why Java was able to cast it to my
    own cMyClass (not a problem to cast a null to
    something else), but when I created a Image (by doing
    a lot of unnessacary difficult stuff), and then tried
    to cast this Image to cMyClass it throw a
    ClassCastException or something like that...
    How can I cast the java.awt.Image class to my class
    anyway?You can't, and if you understood casting then you'd understand that it wouldn't make sense.
    3, 4(don't know)
    Maybe stupid question, but for example the BufferedImage, is this
    completly written in Java?
    How is the link made between the OS+hardware and the Java code? I
    mean, displaying images etc. is very platform dependend not?Look for JNI (Java Native Interface). It's a way to link native (e.g. C) code with Java code.

Maybe you are looking for

  • Best Practices to the management of errors in OIM 9.1.0.2

    Friends, What is the process for handling errors to a failure to implement Oracle Identity Manager 9.1.0.2 Thanks

  • Exporting QT Movie from DVDSP?

    Hi There. I'm working with subtitles for the first time. FCP seems pretty clunky with subtitles so I was going to use a subtitle list with DVDSP. But in addition to building a DVD, I want to export my movie wiht subtitles as QT to post on the web. Is

  • Domestic Partner needs to be added to payroll register in order

    Hi llll, Domestic Partner needs to be added to payroll register in order to reconcile during recon. Help me on this

  • Error opening backup....

    My TC was working just fine - and actually was working very well. All of a sudden, the backup image could not be found. After playing with it for a while, I seemed to get it to find the backup image, however, after 20 hours of continuous backing up (

  • Pidgin fails to start after todays update / segfault in libgstclutter

    Hello, I'm getting this error message since the last update: $ pidgin Xlib: extension "GLX" missing on display ":0.0". ERROR: Caught a segmentation fault while loading plugin file: /usr/lib/gstreamer-0.10/libgstclutter.so Please either: - remove it a