Package com.lightcrafts.image.metadata

Examples of com.lightcrafts.image.metadata.ImageOrientation


        final ImageMetadata metadata = imageInfo.getCurrentMetadata();
        final CoreDirectory dir =
            (CoreDirectory)metadata.getDirectoryFor(
                CoreDirectory.class, true
            );
        final ImageOrientation orientation = getOrientationFrom( metadata );
        dir.putValue(
            CORE_ORIGINAL_ORIENTATION,
            new UnsignedShortMetaValue( orientation.getTIFFConstant() )
        );
    }
View Full Code Here


     *
     * @param metadata The {@link ImageMetadata} to add into.
     */
    private void addOrientation( ImageMetadata metadata ) {
        removeValue( CORE_IMAGE_ORIENTATION );
        final ImageOrientation orientation = getOrientationFrom( metadata );
        putValue(
            CORE_IMAGE_ORIENTATION,
            new UnsignedShortMetaValue( orientation.getTIFFConstant() )
        );
    }
View Full Code Here

     * @param metadata The {@link ImageMetadata} to get the orientation from.
     * @return Returns said orientation or
     * {@link ImageOrientation#ORIENTATION_LANDSCAPE} if none.
     */
    private static ImageOrientation getOrientationFrom( ImageMetadata metadata ) {
        final ImageOrientation orientation = metadata.getOrientation();
        if ( orientation == ORIENTATION_UNKNOWN ) {
            //
            // We decree that there shall always be an orientation value.  If
            // there isn't one, just assume it's landscape.
            //
View Full Code Here

     */
    public ImageOrientation getOrientation() {
        final Collection<ImageMetadataDirectory> dirs =
            findProvidersOf( OrientationProvider.class );
        for ( ImageMetadataDirectory dir : dirs ) {
            final ImageOrientation orientation =
                ((OrientationProvider)dir).getOrientation();
            if ( orientation != ORIENTATION_UNKNOWN )
                return orientation;
        }
        return ORIENTATION_UNKNOWN;
View Full Code Here

        //
        // As a special case, if the "from" metadata has an orientation,
        // replace the orientation in EXIF and TIFF directories, otherwise
        // there will be inconsistent orientations.
        //
        final ImageOrientation orientation = fromMetadata.getOrientation();
        if ( orientation != ORIENTATION_UNKNOWN ) {
            final ImageMetaValue value =
                new UnsignedShortMetaValue( orientation.getTIFFConstant() );
            putValue( EXIFDirectory.class, EXIF_ORIENTATION, value, false );
            putValue( TIFFDirectory.class, TIFF_ORIENTATION, value, false );
        }
    }
View Full Code Here

        //
        // If we are to use the actual orientation, use the authoritative value
        // in the Core directory; otherwise, just use landscape.
        //
        final ImageOrientation orientation = useActualOrientation ?
            metadata.getOrientation() :
            ImageOrientation.ORIENTATION_LANDSCAPE;

        metadata.putValue(
            TIFFDirectory.class, TIFF_ORIENTATION,
            new UnsignedShortMetaValue( orientation.getTIFFConstant() )
        );

        return metadata;
    }
View Full Code Here

        // coordinate system used for regions and crop bounds:
        XmlNode imageNode = root.getChild(ImageTag);
        if (imageNode.hasAttribute(ImageOrientationTag)) {
            String value = imageNode.getAttribute(ImageOrientationTag);
            try {
                ImageOrientation oldOrientation =
                    ImageOrientation.getOrientationFor(Short.parseShort(value));
                ImageOrientation newOrientation = meta.getOrientation();
                if (oldOrientation != newOrientation) {
                    meta.setOrientation(oldOrientation);
                }
            }
            catch (NumberFormatException e) {
                throw new XMLException(
                    "Image orientation \"" + value + "\" is not a number", e
                );
            }
        }
        // Backwards compatibility: before XMP support, the convention in LZN
        // files was that the image orientation was its original orientation,
        // before any browser rotations.
        else {
            // Make sure this pre-XMP LZN structure is not a Template.
            // (See Application.saveTemplate().)
            if (! root.getName().equals("Template")) {
                ImageOrientation origOrient = meta.getOriginalOrientation();
                meta.setOrientation(origOrient);
            }
        }
        engine = EngineFactory.createEngine(meta, versionInfo, thread);
View Full Code Here

        auxInfo = m_imageInfo.getAuxiliaryInfo();

        if (sourceImage == null)
            throw new IOException("Something wrong with opening " + metadata.getFile().getName());

        ImageOrientation orientation = metadata.getOrientation();
        if (orientation != null) {
            transposeAngle = orientation.getCorrection();
            if (transposeAngle != null) {
                ParameterBlock pb = new ParameterBlock();
                pb.addSource(sourceImage);
                pb.add(transposeAngle);
                RenderedOp transposed = JAI.create("Transpose", pb, null);
View Full Code Here

    private static String getDimensionText(ImageMetadata meta) {
        int width = meta.getImageWidth();
        int height = meta.getImageHeight();
        String value = "";
        if ((width > 0) && (height > 0)) {
            ImageOrientation orient = meta.getOrientation();
            switch (orient) {
                case ORIENTATION_90CCW:
                case ORIENTATION_90CCW_VFLIP:
                case ORIENTATION_90CW:
                case ORIENTATION_90CW_HFLIP:
View Full Code Here

    }

    // Rotate the given image according to the given orientation metadata.
    static RenderedImage rotate(RenderedImage image, ImageMetadata meta) {
        if (meta != null) {
            ImageOrientation orient = meta.getOrientation();
            TransposeType transpose = orient.getCorrection();
            if (transpose != null) {
                ParameterBlock pb = new ParameterBlock();
                pb.addSource(image);
                pb.add(transpose);
                image = JAI.create(
View Full Code Here

TOP

Related Classes of com.lightcrafts.image.metadata.ImageOrientation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.