How to resize a gif image

hi
i need to resize a gif image to my preferable height and width . i have copied some code from net , its working fine for small images . but when i resize large images the background becomes back .... so
any body help me put in this....
regards
mano

hi
thanks for ur reply . can u plz tell me were to insert the code here
Image image = Toolkit.getDefaultToolkit().getImage("C:\\image.gif");
MediaTracker mediaTracker = new MediaTracker(new Container());
mediaTracker.addImage(image, 0);
mediaTracker.waitForID(0);
// determine thumbnail size from WIDTH and HEIGHT
int thumbWidth = Integer.parseInt("120");
int thumbHeight = Integer.parseInt("75");
double thumbRatio = (double)thumbWidth / (double)thumbHeight;
int imageWidth = image.getWidth(null);
System.out.println("imageWidth "+ imageWidth);
int imageHeight = image.getHeight(null);
double imageRatio = (double)imageWidth / (double)imageHeight;
if (thumbRatio < imageRatio) {
thumbHeight = (int)(thumbWidth / imageRatio);
} else {
thumbWidth = (int)(thumbHeight * imageRatio);
// draw original image to thumbnail image object and
// scale it to the new size on-the-fly
BufferedImage thumbImage = new BufferedImage(thumbWidth,
thumbHeight, BufferedImage.TYPE_INT_RGB);
Graphics2D graphics2D = thumbImage.createGraphics();
graphics2D.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
RenderingHints.VALUE_INTERPOLATION_BILINEAR);
graphics2D.drawImage(image, 0, 0, thumbWidth, thumbHeight, null);
// save thumbnail image to OUTFILE
BufferedOutputStream out = new BufferedOutputStream(new
FileOutputStream(args[1]));
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
JPEGEncodeParam param = encoder.
getDefaultJPEGEncodeParam(thumbImage);
int quality = Integer.parseInt("75");
quality = Math.max(0, Math.min(quality, 100));
param.setQuality((float)quality / 100.0f, false);
encoder.setJPEGEncodeParam(param);
encoder.encode(thumbImage);
out.close();
System.out.println("Done.");

Similar Messages

  • How to resize animated gif without losing animation?

    I created a wee animated gif a while ago but deleted the original Photoshop file (CS3). I need to resize the gif from 100px to 70px for an avatar. When I've changed the image size in Photoshop (it doesn't show the animation frames), it removes all animation. Is there a way around this?
    Kind regards
    Mel
    The image:

    You can infact use Adobe Macromedia Flash to resize your Gif Image.
    Import your Gif image into Flash and then you can try to resize and export the file as GIF.
    Its kinda weird but it works . 

  • How do you get .gif images to move?

    I know when you take pictures in photo booth you can export it to your iChat account to make it a little animation. But how do i get the .gif images i dragged & dropped from the web to move? I open Preview to view the .gif but it just gives me all the frames of the picture and not really an animation. Can anyone help me make them move?

    I presume you want to have an animated buddy icon?
    In case you have leopard installed;
    1. Select the 4 photo (burst) button in Photo Booth.
    2. Look: 1.straight into the camera and after the flash look 2.left, 3.right an up.
    3. Select the miniature in the photo booth picture bar, if you like it: click on the iChat icon.
    4. Open iChat>preferences>general>tick the box "show animated buddy icons".
    You have an animated buddy icon and you can see your buddy's animations as well, in case they have one.

  • How do u view gif. images

    I been for the longest time wonder how to view gif. images on the ipod

    http://docs.info.apple.com/article.html?artnum=304677

  • How to deploy my gif images

    Hi All,
    I have an application, which has an images in gif format. This gif images I use in the code for to different tree nodes. I declared in a constant the image path eg. "src/TreeModelIcons/" (The src folder where my source is located, I use Eclipse.)
    How can I deploy my app, for use the deployed app correctly the images? Where I want to declare the images? In a JNLP resorce section I want to define them? In a jar file contain the TreeModelIcons folder with all image. What is a correct way? What can I do for my app use the images correctly? (If I run localy my app works perfectly.)
    Thank you

    We put our image files in the jar to preserve the directory structure... Works fine for us. Don't know if this is the "correct" way to do it, but...

  • How to resize a uploaded image in stage

    Hi everybody, I am a very fresh guy in AS 3.0 and I am a novoice in this script.
    I have got a task to create project of dynamic banner generation.
    here I need to upload a image file. Then I need to handle the resize, rotate and alpha property to the image loaded dynamically.
    then I need to add text fields for adding text and need to change the font type, size, rotate, alpha for the text. you can add 1 or more text.
    then similarly i needed to draw shapes and need to handle the alpha, resizing, color property for the drawn shapes.
    After all the thing are done in the stage, then i have a publish button. when clicked this must create a swf file of the size of the bg image.
    I know that this is a big task, but helps will make this thro' . ( I also need suggestions that how to start it along)
    Thanks a lot for any helps.
    krsmk

    Dietmar,
    When I right-click on the image I could only save the image in .bmp format. But I have found out that my browser (or pc) causes this problem. I have downloaded the files on a other PC. I Think this problem is related to my export problem (exporting application problem
    Thanks for your reply.
    Please let me know If you have any idea what causes these problems.
    Fred.

  • How To Resize Animated GIF's All At Once?

    I have seen people say you can resize an animated GIF in
    Fireworks without doing it one frame at a time, but nobody says
    exactly how. Maybe I'm missing something simple, but is this
    possibe and if so, how do you do it?
    I tried using the forum search but it didn't find any
    results.
    I'm using Fireworks 9.0.1.1213 if that makes a
    difference.

    If you look in the frames window, you will see that each
    frame has a gray
    box on the left. Click that gray box by the first frame and
    the last frame
    to turn on onion skinning. You'll know if it worked because
    there will be
    two little icons, one pointing up and the other pointing
    down, with a line
    connecting them through all the onion skinned frames.
    HTH;
    Amy
    "Louie55" <[email protected]> wrote in
    message
    news:fum5i1$s9c$[email protected]..
    >I have seen people say you can resize an animated GIF in
    Fireworks without
    > doing it one frame at a time, but nobody says exactly
    how. Maybe I'm
    > missing
    > something simple, but is this possibe and if so, how do
    you do it?
    >
    > I tried using the forum search but it didn't find any
    results.
    >
    > I'm using Fireworks 9.0.1.1213 if that makes a
    difference.
    >

  • How can I create GIF images in Photoshop?

    Hi,
    I want to create GIF animated images for my website named is http://www.veominfotech.com. I have tried but there is some problem with image smoothness. Can you suggest me a solution how I can give smoothness in GIF animated file.
    OR
    Can you suggest me any other software where i can create GIF animated image.

    Add more frames.  See link below for details.
    http://www.bigstockphoto.com/blog/creating-simple-yet-effective-animated-gifs-in-photoshop
    Nancy O.

  • How to Modifying a GIF image(Discontinued)

    Wrong forum.. This belongs to the Java Advanced Imaging forum. I have reposted it.
    Message was edited by:
    DJ_Viking
    Message was edited by:
    DJ_Viking

    hi
    thanks for ur reply . can u plz tell me were to insert the code here
    Image image = Toolkit.getDefaultToolkit().getImage("C:\\image.gif");
    MediaTracker mediaTracker = new MediaTracker(new Container());
    mediaTracker.addImage(image, 0);
    mediaTracker.waitForID(0);
    // determine thumbnail size from WIDTH and HEIGHT
    int thumbWidth = Integer.parseInt("120");
    int thumbHeight = Integer.parseInt("75");
    double thumbRatio = (double)thumbWidth / (double)thumbHeight;
    int imageWidth = image.getWidth(null);
    System.out.println("imageWidth "+ imageWidth);
    int imageHeight = image.getHeight(null);
    double imageRatio = (double)imageWidth / (double)imageHeight;
    if (thumbRatio < imageRatio) {
    thumbHeight = (int)(thumbWidth / imageRatio);
    } else {
    thumbWidth = (int)(thumbHeight * imageRatio);
    // draw original image to thumbnail image object and
    // scale it to the new size on-the-fly
    BufferedImage thumbImage = new BufferedImage(thumbWidth,
    thumbHeight, BufferedImage.TYPE_INT_RGB);
    Graphics2D graphics2D = thumbImage.createGraphics();
    graphics2D.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
    RenderingHints.VALUE_INTERPOLATION_BILINEAR);
    graphics2D.drawImage(image, 0, 0, thumbWidth, thumbHeight, null);
    // save thumbnail image to OUTFILE
    BufferedOutputStream out = new BufferedOutputStream(new
    FileOutputStream(args[1]));
    JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
    JPEGEncodeParam param = encoder.
    getDefaultJPEGEncodeParam(thumbImage);
    int quality = Integer.parseInt("75");
    quality = Math.max(0, Math.min(quality, 100));
    param.setQuality((float)quality / 100.0f, false);
    encoder.setJPEGEncodeParam(param);
    encoder.encode(thumbImage);
    out.close();
    System.out.println("Done.");

  • How to resize the TIFF image in JAI

    public static final void appendImage(String fileName, Document doc, PdfWriter writer)
    throws Exception {
    try {
    /* using the Java Advanced Imaging API to deal with tiffs */
    if ( ImageUtil.isTif(fileName) ) {
    LOG.debug("We are dealing with a tiff ...");
    File file = new File(fileName);
    SeekableStream s = new FileSeekableStream(file);
    ImageDecoder dec = ImageCodec.createImageDecoder("tiff", s, null);
    System.out.println("Number of images in this TIFF: " + dec.getNumPages());
    PdfContentByte cb = writer.getDirectContent();
    for (int k = 0; k < dec.getNumPages(); ++k) {
    RenderedImage ri = dec.decodeAsRenderedImage(k);
    Raster ra = ri.getData();
    BufferedImage bi = new BufferedImage(ri.getColorModel(),Raster.createWritableRaster(ri.getSampleModel(), ra.getDataBuffer(), null), false, new Hashtable());
              LOG.debug("The Buffered Image is :" + bi);
    Image img = Image.getInstance(bi, null, true);
              //Sreenivas added for Oregon
              img.rawData();
              LOG.debug("The RawData is:");
              img.scaledHeight();
              LOG.debug("The rheight:");
              img.scaledWidth();
    LOG.debug("The rwidth is:");
              //Sreenivas Ended
    img.scalePercent(36);
              LOG.debug("The Scale Percent is:" + img);
              float y = doc.top() - img.scaledHeight();
              //float x = doc.top() - img.scaledWidth();//Sreenivas added for Oregon
    img.setAbsolutePosition(0, y);
    LOG.debug("Top Position..."+ y );
    doc.newPage();
    cb.addImage(img);
    /* the Toolkit can handle GIF, JPEG or PNG. */
    else {
    java.awt.Image coreImage = Toolkit.getDefaultToolkit().createImage(fileName);
    Image image = Image.getInstance(coreImage, null);
    image.setAbsolutePosition(0, 0);
    doc.newPage();
    doc.add(image);
    LOG.debug("Added image "+fileName);
    catch (Throwable t) {
    LOG.error(t);
    doc.add(new Chunk(t.getMessage()));
    I have written like this.. Image has been display,but it cutting

    public static final void appendImage(String fileName,
    Document doc, PdfWriter writer)
    throws Exception {
    try {
    /* using the Java Advanced Imaging API to deal
    o deal with tiffs */
    if ( ImageUtil.isTif(fileName) ) {
    LOG.debug("We are dealing with a tiff ...");
    File file = new File(fileName);
    SeekableStream s = new
    s = new FileSeekableStream(file);
    ImageDecoder dec =
    er dec = ImageCodec.createImageDecoder("tiff", s,
    null);
    System.out.println("Number of images in this
    in this TIFF: " + dec.getNumPages());
    PdfContentByte cb =
    yte cb = writer.getDirectContent();
    for (int k = 0; k < dec.getNumPages(); ++k)
    (); ++k) {
    RenderedImage ri =
    Image ri = dec.decodeAsRenderedImage(k);
    Raster ra = ri.getData();
    BufferedImage bi = new
    e bi = new
    BufferedImage(ri.getColorModel(),Raster.createWritable
    Raster(ri.getSampleModel(), ra.getDataBuffer(),
    null), false, new Hashtable());
              LOG.debug("The Buffered Image is :" + bi);
    Image img = Image.getInstance(bi, null,
    (bi, null, true);
              //Sreenivas added for Oregon
              img.rawData();
              LOG.debug("The RawData is:");
              img.scaledHeight();
              LOG.debug("The rheight:");
              img.scaledWidth();
    LOG.debug("The rwidth is:");
              //Sreenivas Ended
    img.scalePercent(36);
              LOG.debug("The Scale Percent is:" + img);
              float y = doc.top() - img.scaledHeight();
    //float x = doc.top() -
    () - img.scaledWidth();//Sreenivas added for Oregon
    img.setAbsolutePosition(0, y);
    LOG.debug("Top Position..."+ y );
    doc.newPage();
    cb.addImage(img);
    /* the Toolkit can handle GIF, JPEG or PNG. */
    else {
    java.awt.Image coreImage =
    eImage =
    Toolkit.getDefaultToolkit().createImage(fileName);
    Image image = Image.getInstance(coreImage,
    reImage, null);
    image.setAbsolutePosition(0, 0);
    doc.newPage();
    doc.add(image);
    LOG.debug("Added image "+fileName);
    catch (Throwable t) {
    LOG.error(t);
    doc.add(new Chunk(t.getMessage()));
    I have written like this.. Image has been
    display,but it cutting,pls some body help me..i will be very happy..Thank u lot

  • How can i Save Gif image

    I download the JDK 1.4.0-beta and the imageio Package.
    I try to save a BufferedImage in the JPEG format, it's OK but when i use the gif format an empty file is created. What package do i need to save bufferedImage in gif Format ? ? ?

    I hope this could help :
    http://www.acme.com/java/software/Acme.JPM.Encoders.GifEncoder.html#_top_
    Adaya .

  • How I resized the Small Image for a Product Module

    I wanted a big picture for my small product module.
    1. I inserted {tag_largeimage} in place of {tag_smallimage} on the small product module.
    Site Manager -> Module Templates -> Online Shop -> Individual Product Small.
    The picture was 200 X 275. It was getting cut off.
    2. I open File Manager -> CSS and look in style.css for numbers smaller than those dimensions.
    At the bottom, at lines 1594/1595 I found what I was looking for: "#content .shop-product-small .image".
    3. I increased the dimensions to 200*275. If your site is automatically generating a border you'll need to include them in the final dimensions.
    The customer gets a better view of what I'm selling. I'm happy with the result. I hope this helps.

    Hi Steve,
    You should just use the large product image, use _path to get the raw URL of the image and use the tumbnail generation code (see knowledgebase) and specify your dimensions. This allows you to use then properly use a large product image in your detail view

  • How to resize a jpg/gif file to a fix size using jimi ?

    I have search from the web and didn't find any example on doing this.
    Can any one give example on how to resize a jpg image. let say 120x240
    to a fixed size 40x40 ?
    thank you

    Hi.
    When you got that image in form of a file, just load it and invoke the image's getScaledInstance(...)-method.
    Here's how it could work:
    import java.awt.*;
    public class Test {
    public static void main(String[] argv) {
      // define where the image comes from:
      URL toImage = new URL("file:/C:/test.jpg");  // or the like
      // get the image:
      Image image = Toolkit.getDefaultToolkit().createImage(toImage);
      // scale the image to target size (40x40 here):
      Image smallImage = image.getScaledInstance(40, 40, Image.SCALE_DEFAULT);
      // you might want to do other things like displaying it afterwards
    }HTH & cheers,
    kelysar

  • How to resize image in JSP using JAI ??!!

    Please help me how to resize an JPEG image from my JSP, could I use JAI lib ? how ?

    Hello,
    I had the same problem few months ago ( in that case i used Jimi instead of JAI).
    The answer to your question is: use the java class called "Image".
    Infact you can use JAI just for load or save to disk your image that you have to resize and then use the following code to resize the image :
    Image imgResized = img.getScaledInstance(100,1,Image.SCALE_AREA_AVERAGING);
    The object "img" is the image to resize and the object "imgResized" is the image resized with width equals to 100 and with a right height.
    I used Jimi just to save my image and i think that with JAI there is a method to do this.
    You can use JAI to load in memory your image too so you can avoid problem with MediaTraker class.
    I hope that this can help you.
    Cheers.
    Stefano

  • RESIZING GIF IMAGES WITHOUT LOSING ANIMATION

    Is it possible to resize a Gif image without losing animation?  I tried but unfortunately lost the animation. I use CS3 Extended.  Thanks

    No, I don't think so. for that, you'd probably have to import your animation using the Video to Layers option, resize, then rebuild the animation and export it.
    Mylenium

Maybe you are looking for

  • Itunes 12 not playing podcasts in correct order

    I upgraded to the new version of itunes and ever since it will not play the oldest podcast to newest as it used to do in itunes 11.  I found the settings and changed the setting to play from oldest to newest, I even changed the setting to show oldest

  • Variance Analysis Help

    Dear All I have created a Scenario to tackle variance analysis and called ActualvsBudget Example is Revenue Actual - Budget = Variance. The problem I have is that the Favourable or Adverse variance works at accounte level however is distorted when co

  • Making a graph in java

    Hi I want to take data from a mySQL database and show it in an applet as a graph. The problem I'm having is creating the graph. Does anyone know a fairly simple way to do this? thanks

  • Converting to DNG - which Camera Raw compatiabilty and why?

    When converting camera Raw files in Lightroom 2.5, a dialog box asks which Camera Raw/Photoshop version I want to make DNG file compatible with.   (See my screengrab below) I understand why Adobe made different vesions of Camera Raw and stopped suppo

  • "Adobe Photoshop funkioniert nicht mehr"

    Bei der Zusammenstellung für eine Collage erhalte ich oige Meldung. Dazu heißt es: "Das Programm wird aufgrund eines Problems geschlossen und sie werden benachrrichtigt, wenn eine Lösung bekannt ist." Hierauf warte ich schon mehrere Tage! Was soll ic