0

I am currently using http://code.google.com/p/java-image-scaling/ this library to generate scaled images for my web app.But when I scale down the image to about 100x100 size there are some leftover artifacts visible in some images. Is this an issue with antialiasing? And how do I use antialiasing with this library.The api documentation doesn't say any thing about it.

Here is the code

File f = new File("C:\\Users\\ad min\\Pictures\\30-whisky-3d-wallpaper-1152x864.jpg");
        BufferedImage src = ImageIO.read(f);

        //ResampleOp resampleOp = new ResampleOp(76, 76);
        ResampleOp resampleOp = new ResampleOp(200,200);
        resampleOp.setUnsharpenMask(AdvancedResizeOp.UnsharpenMask.VerySharp);
        BufferedImage rescaled = resampleOp.filter(src, null);

        ImageIO.write(rescaled, "JPG", new File(
                "C:\\Users\\ad min\\Pictures\\scaleddown.jpg"));

what am I doing wrong?

Nav
  • 10,304
  • 20
  • 56
  • 83
  • Consider if you really need this library. You can also scale images with built-in class BufferedImage. As far as I know (used it, but not too much), there aren't any artifacts when using this class. You should test it :) – m4tx Sep 08 '12 at 11:19
  • I really got some artifacts when saving rescaled images to jpg..but still better than imgscalr library..can u plz tell me how to enable antialiasing with this library – Nav Sep 08 '12 at 11:23
  • *"there are some leftover artifacts visible in some images."* A picture paints a thousand words. But heck, make it 2000 words with an 'unscaled no artifacts' & 'scaled with artifacts' comparison. – Andrew Thompson Sep 08 '12 at 12:41

1 Answers1

0

I finally didn't need antialiasing I simply used this code given in the foloowing link and it worked :) whewww

http://www.universalwebservices.net/web-programming-resources/java/adjust-jpeg-image-

compression-quality-when-saving-images-in-java
        Iterator<ImageWriter> iter = ImageIO
                .getImageWritersByFormatName("jpeg");
        ImageWriter writer = (ImageWriter) iter.next();
        // instantiate an ImageWriteParam object with default compression
        // options
        ImageWriteParam iwp = writer.getDefaultWriteParam();
        iwp.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
        iwp.setCompressionQuality(1); // an integer between 0 and 1
        // 1 specifies minimum compression and maximum quality
        File file = new File("C:\\Users\\ad min\\Pictures\\scaleddown.jpg");
        FileImageOutputStream output = new FileImageOutputStream(file);
        writer.setOutput(output);
        IIOImage image = new IIOImage(rescaled, null, null);
        writer.write(null, image, iwp);
        writer.dispose();
Nav
  • 10,304
  • 20
  • 56
  • 83