Skip to main content

Resizing Images Results in Image Artifacts

1 reply [Last post]
Joined: 2006-02-17

I'm not sure I am posting this in the correct place, but would appreciate suggestions....

I created a simple Java class for a client to resize JPEG images in the current directory but when he uses it, occasionally (7 of 30 images) a black line - either vertical or horizontal - appears on the saved image. He is using Java 1.4.2_07 running on Windows XP.

The scaling is done with:

AffineTransformOp op = new AffineTransformOp( AffineTransform.getScaleInstance(scale, scale), hintlist );
bi = op.filter( bi, null );

Where bi is a loaded BufferedImage, and the result is written back out thusly:

FileOutputStream out = new FileOutputStream(fileName);
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam(bi);
param.setQuality(quality, false);
encoder.encode(bi, param);

if one of these hints are used:

hintlist.put( RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR );
hintlist.put( RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY );

then the resulting image appears as though it was a negative, with a reddish hue.

Any suggestions, pointers, advice would be appreciated!

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Mister Chris
Joined: 2006-02-17


I get the same black JPEG when setting the hints to high quality, even with Java 1.5

Any help is highly appreciated