GithubHelp home page GithubHelp logo

Comments (4)

GoogleCodeExporter avatar GoogleCodeExporter commented on August 22, 2024
I'm unable to reproduce the problem in 0.8.2 (just released). I suspect the 
error
report is about 0.8.1 (even though is says 0.8.2).
I case I'm wrong, please provide me with a full code example (I'm currently 
using the
one below):

BufferedImage image2D = 
ImageIO.read(getClass().getResourceAsStream("issue11.jpg"));
DimensionConstrain dc = DimensionConstrain.createMaxDimension(604,604, true);
ResampleOp  resampleOp = new ResampleOp (dc);
BufferedImage rescaledTomato = resampleOp.filter(image2D, null);

Original comment by m%[email protected] on 3 Nov 2009 at 2:42

  • Changed state: WontFix

from java-image-scaling.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 22, 2024
I downloaded 8.3 jar and works with no exception now. However the rescaling 
seem to
have reduce some quality of the original. I have attached the rescaled of the
previous attached photo. There are extra white shadow around the white part of 
the
picture which dont exist from the original.

Here is the code i use:

BufferedImage bi = ImageIO.read(src);

         DimensionConstrain dc =DimensionConstrain.createMaxDimension(604,604, true);
       ResampleOp resampleOp = new ResampleOp(dc);

            resampleOp.setUnsharpenMask(AdvancedResizeOp.UnsharpenMask.Soft);
            BufferedImage rescaled = resampleOp.filter(bi,null);

             File outfile = new File("/Users/charlie/Development/java/playSe/"+ file
+".jpg");
            javax.imageio.ImageIO.write(rescaled, "jpg", outfile);

Original comment by [email protected] on 5 Nov 2009 at 10:08

Attachments:

from java-image-scaling.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 22, 2024
Ok. It seems to be a problem. It must be related to the file format (Grayscale
jpegs). If the source image is saved as png, there is no problem.

The wierd thing is that in my IDE (IntelliJ) there is actually also white noise 
on
the source image as well.

I'll look at it.

Original comment by m%[email protected] on 11 Nov 2009 at 8:19

  • Changed state: Accepted

from java-image-scaling.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 22, 2024
I figured out what is wrong. The rescale works as intended - the white shadows 
is
created by the jpeg compression.

To fix it simply choose a lossless format (such as png) or increase the jpeg 
quality
using the following code:
private void saveHighqualityJpeg(BufferedImage rescaledTomato, String filename)
throws IOException {
        ImageWriter writer = null;
        Iterator iter = ImageIO.getImageWritersByFormatName("jpg");
        if (iter.hasNext()) {
            writer = (ImageWriter)iter.next();
        }

        FileOutputStream fos = new FileOutputStream(filename);
        ImageOutputStream ios = ImageIO.createImageOutputStream(fos);
        writer.setOutput(ios);
        ImageWriteParam iwparam = writer.getDefaultWriteParam();
        iwparam.setCompressionMode(ImageWriteParam.MODE_EXPLICIT) ;
        System.out.println(iwparam.getCompressionQuality()) ;
        iwparam.setCompressionQuality(1.0f) ;
        writer.write(null, new IIOImage(rescaledTomato, null, null), iwparam);
        writer.dispose();
        ios.close();
        fos.close();
    }

Original comment by m%[email protected] on 29 Dec 2009 at 7:19

  • Changed state: Fixed

from java-image-scaling.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.