Domanda

I am copying tiff image files from one directory to another, and need to rotate them 90 degrees clockwise to correct their page orientation. The images are technical drawings, and are already of not-great quality, so I need to use as lossless a technique as possible. There will potentially be thousands of drawings to process per daily batch, so memory- and time-efficiency are also both considerations.

I do very little image processing, so I am not very familiar with the available libraries for this. After doing some reading, I'm thinking of using JAI's "transpose":

http://docs.oracle.com/cd/E17802_01/products/products/java-media/jai/forDevelopers/jai-apidocs/javax/media/jai/operator/TransposeDescriptor.html

Can anyone who has used this technique recommend for or against it in terms of function or efficiency?

Any recommendations for other approaches?

È stato utile?

Soluzione

Well, if you only want to rotate them by 90 degrees, you only need to read the columns of the image and write them as rows. no loss at all then.

Pseudocode:

for x in oldimage.width
    for y in oldimage.height
        newimage[y][x] = oldimage[x][y]

Altri suggerimenti

You could look into using something like this:

PlanarImage pi = PlanarImage.wrapRenderedImage(image);
        BufferedImage bi = pi.getAsBufferedImage();
        AffineTransform at = new AffineTransform();
        at.translate(-(image.getWidth() - image.getHeight()) / 2, (image.getWidth() - image.getHeight()) / 2);
        at.rotate(Math.toRadians(90),bi.getWidth()/2,bi.getHeight() / 2);
        AffineTransformOp opRotated = new AffineTransformOp(at,
                    AffineTransformOp.TYPE_BILINEAR);
        image = opRotated.filter(bi, null);
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top