473,385 Members | 1,919 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

createScaledRendering weird problem when create small thumbnail

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/sunb...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(nul l);
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");
}
/************************************************** *****************/
Jul 17 '05 #1
2 3861
On 28 Jun 2004 07:44:53 -0700, xj******@yahoo.com
(xj******@hotmail.com) wrote or quoted :
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


Gifs only look decent resized when you scale them by powers of two.
If you want something that scales well, use JPEG.

--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
Jul 17 '05 #2
xj******@yahoo.com (xj******@hotmail.com) wrote in message news:<a9**************************@posting.google. com>...
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/sunb...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(nul l);
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");
}
/************************************************** *****************/


Here is my new code, the scaled picture looks alright this time

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(nul l);
RenderableImage ren = JAI.createRenderable("renderable", pb);

int h = source.getHeight();
int w = source.getWidth();
PlanarImage dst = (PlanarImage)ren.createScaledRendering(w, h, null);

pb = new ParameterBlock();
pb.addSource(dst);
pb.add(0.3f); // 0.3 is just some test data
pb.add(0.3f);
pb.add(0.0f);
pb.add(0.0f);
pb.add(new InterpolationNearest()); // <-- this is the key
PlanarImage transformedImage = JAI.create("scale", pb, null);
JAI.create("filestore",transformedImage,file2,"PNG ");
}
================================================== =========
I have to use JAI.create("scale",pb,hints)
rather than createScaledRendering(w, h, hints) to make it working.
Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Mike | last post by:
Sites using thumbnail preview for world wide web file navigation and searching. Below are list of sites that are either researching or providing thumbnail preview images for online web...
7
by: Chris Perry | last post by:
How do you create a thumbnail constrained to a box, without distorting and but making where it doesn't fill the box transparent. I'm two thirds there : Size fitImageSize =...
2
by: David Elliott | last post by:
I am creating a control to display GIF/JPEG images for my website. The control has a Panel to hold the images. I would like to perform the following. 1) store the original on disk and create a...
6
by: Chris D | last post by:
Hi, I have an application where a user uploads an image and I create two thumbnails. One a small image and the second is a larger image but still smaller then the original. I store these in SQL...
1
by: Xah Lee | last post by:
The following is a program to generate thumbnail images for a website. Useful, if you want to do that. It is used to generate the thumbnails for my “Banners, Damsels, and Mores” project...
1
by: Summercoolness | last post by:
In PIL, since thumbnail() first makes a draft copy of the image, and then resize it, so thumbnail() can run a lot faster than resize() because draft() seems a lot faster when resizing from very big...
8
by: barb | last post by:
So that the world at large benefits from our efforts, here is one fully documented way to use Windows Irfanview freeware to create thumbnail web galleries (http://www.irfanview.com). STEP 1:...
10
by: Mike Copeland | last post by:
On my main page I have a small picture - it's actually too small to be useful. I only have it there to show that there's something to look at, but I don't know how to "expand" it so it can be seen...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.