문제

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?

도움이 되었습니까?

해결책

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]

다른 팁

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);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top