createScaledRendering weird problem when create small thumbnail

From: xj92wang_at_hotmail.com (xj92wang_at_yahoo.com)
Date: 06/28/04


Date: 28 Jun 2004 07:44:53 -0700

I have following code to convert a big image to smaller thumbnail,
it work's fine until one day this image come out

http://www.here4now.com/mobdata/sunbleached/Untitled-2.gif

The original size is 200x205, if I resize it to 101x103, it looks
still fine, but one pixed smaller , say 100x102, the result image is
total unacceptable.

Any help or hint will be appreciate

Ivan Wang

P.S. I didn't use Image.getScaledInstance to resize the image because
our server don't have X-window installed.

/*******************************************************************/
public static void resize(String file1, String file2){
      source = JAI.create("fileload", file1);
      ParameterBlock pb = new ParameterBlock();
      pb.addSource(source);
      pb.add(null).add(null).add(null).add(null).add(null);
      RenderableImage ren = JAI.createRenderable("renderable", pb);
      pb = new ParameterBlock();
      pb.addSource(ren);
      int w = source.getWidth()/2;
      int h = source.getHeight()/2;
      //RenderingHints renderingHints = new RenderingHints( null );
      //renderingHints.put( RenderingHints.KEY_COLOR_RENDERING,
      // RenderingHints.VALUE_COLOR_RENDER_QUALITY );
      PlanarImage dst = (PlanarImage)ren.createScaledRendering(w, h,
null);
      JAI.create("filestore",dst,file2,"PNG");
}
/*******************************************************************/



Relevant Pages

  • createScaledRendering weird problem when create small thumbnail
    ... I have following code to convert a big image to smaller thumbnail, ... The original size is 200x205, if I resize it to 101x103, it looks ... public static void resize(String file1, String file2){ ...
    (comp.lang.java.help)
  • Re: Brain dead... write image to file
    ... function resize(){ ... use the SECOND parameter to ... $origStream = imagecreatefromstring; ... // calculate thumbnail size, retaining aspect ratio ...
    (php.general)
  • Re: What is the best way to resize an image?
    ... Sure Rudy: ... The browser will resize it to the specified height and width. ... >> links on each thumbnail to the full-sized image, you may not want to make ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: slow image resize... any alternatives?
    ... > I do know that programs like Photoshop and even Windows XP's thumbnail file ... > thumbnail directory view of a folder of 100 pictures in a matter of seconds, ... > whereas it takes minutes to do so with php. ... > process where they are initially resize using the much faster non-bicubic ...
    (alt.php)
  • Re: Brain dead... write image to file
    ... function resize(){global $blob_arr; ... <?php} ?> ... $origStream = imagecreatefromstring; ... // calculate thumbnail size, retaining aspect ratio ...
    (php.general)