當前位置: 首頁>>代碼示例>>Java>>正文


Java Metadata.addDirectory方法代碼示例

本文整理匯總了Java中com.drew.metadata.Metadata.addDirectory方法的典型用法代碼示例。如果您正苦於以下問題:Java Metadata.addDirectory方法的具體用法?Java Metadata.addDirectory怎麽用?Java Metadata.addDirectory使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.drew.metadata.Metadata的用法示例。


在下文中一共展示了Metadata.addDirectory方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: extract

import com.drew.metadata.Metadata; //導入方法依賴的package包/類
public void extract(@NotNull SequentialReader reader, @NotNull Metadata metadata)
{
    Directory directory = new AdobeJpegDirectory();
    metadata.addDirectory(directory);

    try {
        reader.setMotorolaByteOrder(false);

        if (!reader.getString(PREAMBLE.length()).equals(PREAMBLE)) {
            directory.addError("Invalid Adobe JPEG data header.");
            return;
        }

        directory.setInt(AdobeJpegDirectory.TAG_DCT_ENCODE_VERSION, reader.getUInt16());
        directory.setInt(AdobeJpegDirectory.TAG_APP14_FLAGS0, reader.getUInt16());
        directory.setInt(AdobeJpegDirectory.TAG_APP14_FLAGS1, reader.getUInt16());
        directory.setInt(AdobeJpegDirectory.TAG_COLOR_TRANSFORM, reader.getInt8());
    } catch (IOException ex) {
        directory.addError("IO exception processing data: " + ex.getMessage());
    }
}
 
開發者ID:drewnoakes,項目名稱:metadata-extractor,代碼行數:22,代碼來源:AdobeJpegReader.java

示例2: readMetadata

import com.drew.metadata.Metadata; //導入方法依賴的package包/類
/**
 * Reads metadata from an {@link InputStream} of known length.
 *
 * @param inputStream a stream from which the file data may be read.  The stream must be positioned at the
 *                    beginning of the file's data.
 * @param streamLength the length of the stream, if known, otherwise -1.
 * @return a populated {@link Metadata} object containing directories of tags with values and any processing errors.
 * @throws ImageProcessingException if the file type is unknown, or for general processing errors.
 */
@NotNull
public static Metadata readMetadata(@NotNull final InputStream inputStream, final long streamLength) throws ImageProcessingException, IOException
{
    BufferedInputStream bufferedInputStream = inputStream instanceof BufferedInputStream
        ? (BufferedInputStream)inputStream
        : new BufferedInputStream(inputStream);

    FileType fileType = FileTypeDetector.detectFileType(bufferedInputStream);

    Metadata metadata = readMetadata(bufferedInputStream, streamLength, fileType);

    metadata.addDirectory(new FileTypeDirectory(fileType));

    return metadata;
}
 
開發者ID:drewnoakes,項目名稱:metadata-extractor,代碼行數:25,代碼來源:ImageMetadataReader.java

示例3: extract

import com.drew.metadata.Metadata; //導入方法依賴的package包/類
/**
 * Performs the XMP data extraction, adding found values to the specified instance of {@link Metadata}.
 * <p>
 * The extraction is done with Adobe's XMPCore library.
 */
public void extract(@NotNull final byte[] xmpBytes, int offset, int length, @NotNull Metadata metadata, @Nullable Directory parentDirectory)
{
    XmpDirectory directory = new XmpDirectory();

    if (parentDirectory != null)
        directory.setParent(parentDirectory);

    try {
        XMPMeta xmpMeta;

        // If all xmpBytes are requested, no need to make a new ByteBuffer
        if (offset == 0 && length == xmpBytes.length) {
            xmpMeta = XMPMetaFactory.parseFromBuffer(xmpBytes);
        } else {
            ByteBuffer buffer = new ByteBuffer(xmpBytes, offset, length);
            xmpMeta = XMPMetaFactory.parse(buffer.getByteStream());
        }

        directory.setXMPMeta(xmpMeta);
    } catch (XMPException e) {
        directory.addError("Error processing XMP data: " + e.getMessage());
    }

    if (!directory.isEmpty())
        metadata.addDirectory(directory);
}
 
開發者ID:drewnoakes,項目名稱:metadata-extractor,代碼行數:32,代碼來源:XmpReader.java

示例4: extract

import com.drew.metadata.Metadata; //導入方法依賴的package包/類
/**
 * Performs the Jfif data extraction, adding found values to the specified
 * instance of {@link Metadata}.
 */
public void extract(@NotNull final RandomAccessReader reader, @NotNull final Metadata metadata)
{
    JfifDirectory directory = new JfifDirectory();
    metadata.addDirectory(directory);

    try {
        // For JFIF, the tag number is also the offset into the segment

        directory.setInt(JfifDirectory.TAG_VERSION,      reader.getUInt16(JfifDirectory.TAG_VERSION));
        directory.setInt(JfifDirectory.TAG_UNITS,        reader.getUInt8(JfifDirectory.TAG_UNITS));
        directory.setInt(JfifDirectory.TAG_RESX,         reader.getUInt16(JfifDirectory.TAG_RESX));
        directory.setInt(JfifDirectory.TAG_RESY,         reader.getUInt16(JfifDirectory.TAG_RESY));
        directory.setInt(JfifDirectory.TAG_THUMB_WIDTH,  reader.getUInt8(JfifDirectory.TAG_THUMB_WIDTH));
        directory.setInt(JfifDirectory.TAG_THUMB_HEIGHT, reader.getUInt8(JfifDirectory.TAG_THUMB_HEIGHT));
    } catch (IOException me) {
        directory.addError(me.getMessage());
    }
}
 
開發者ID:drewnoakes,項目名稱:metadata-extractor,代碼行數:23,代碼來源:JfifReader.java

示例5: extract

import com.drew.metadata.Metadata; //導入方法依賴的package包/類
/**
 * Performs the DHT tables extraction, adding found tables to the specified
 * instance of {@link Metadata}.
 */
public void extract(@NotNull final SequentialReader reader, @NotNull final Metadata metadata)
{
    HuffmanTablesDirectory directory = metadata.getFirstDirectoryOfType(HuffmanTablesDirectory.class);
    if (directory == null) {
        directory = new HuffmanTablesDirectory();
        metadata.addDirectory(directory);
    }

    try {
        while (reader.available() > 0) {
            byte header = reader.getByte();
            HuffmanTableClass tableClass = HuffmanTableClass.typeOf((header & 0xF0) >> 4);
            int tableDestinationId = header & 0xF;

            byte[] lBytes = getBytes(reader, 16);
            int vCount = 0;
            for (byte b : lBytes) {
                vCount += (b & 0xFF);
            }
            byte[] vBytes = getBytes(reader, vCount);
            directory.getTables().add(new HuffmanTable(tableClass, tableDestinationId, lBytes, vBytes));
        }
    } catch (IOException me) {
        directory.addError(me.getMessage());
    }

    directory.setInt(HuffmanTablesDirectory.TAG_NUMBER_OF_TABLES, directory.getTables().size());
}
 
開發者ID:drewnoakes,項目名稱:metadata-extractor,代碼行數:33,代碼來源:JpegDhtReader.java

示例6: readJpegSegments

import com.drew.metadata.Metadata; //導入方法依賴的package包/類
public void readJpegSegments(@NotNull Iterable<byte[]> segments, @NotNull Metadata metadata, @NotNull JpegSegmentType segmentType)
{
    for (byte[] segmentBytes : segments) {
        JpegCommentDirectory directory = new JpegCommentDirectory();
        metadata.addDirectory(directory);

        // The entire contents of the directory are the comment
        directory.setStringValue(JpegCommentDirectory.TAG_COMMENT, new StringValue(segmentBytes, null));
    }
}
 
開發者ID:drewnoakes,項目名稱:metadata-extractor,代碼行數:11,代碼來源:JpegCommentReader.java

示例7: extract

import com.drew.metadata.Metadata; //導入方法依賴的package包/類
public void extract(byte[] segmentBytes, Metadata metadata, JpegSegmentType segmentType)
{
    JpegDirectory directory = new JpegDirectory();
    metadata.addDirectory(directory);

    // The value of TAG_COMPRESSION_TYPE is determined by the segment type found
    directory.setInt(JpegDirectory.TAG_COMPRESSION_TYPE, segmentType.byteValue - JpegSegmentType.SOF0.byteValue);

    SequentialReader reader = new SequentialByteArrayReader(segmentBytes);

    try {
        directory.setInt(JpegDirectory.TAG_DATA_PRECISION, reader.getUInt8());
        directory.setInt(JpegDirectory.TAG_IMAGE_HEIGHT, reader.getUInt16());
        directory.setInt(JpegDirectory.TAG_IMAGE_WIDTH, reader.getUInt16());
        short componentCount = reader.getUInt8();
        directory.setInt(JpegDirectory.TAG_NUMBER_OF_COMPONENTS, componentCount);

        // for each component, there are three bytes of data:
        // 1 - Component ID: 1 = Y, 2 = Cb, 3 = Cr, 4 = I, 5 = Q
        // 2 - Sampling factors: bit 0-3 vertical, 4-7 horizontal
        // 3 - Quantization table number
        for (int i = 0; i < (int)componentCount; i++) {
            final int componentId = reader.getUInt8();
            final int samplingFactorByte = reader.getUInt8();
            final int quantizationTableNumber = reader.getUInt8();
            final JpegComponent component = new JpegComponent(componentId, samplingFactorByte, quantizationTableNumber);
            directory.setObject(JpegDirectory.TAG_COMPONENT_DATA_1 + i, component);
        }
    } catch (IOException ex) {
        directory.addError(ex.getMessage());
    }
}
 
開發者ID:drewnoakes,項目名稱:metadata-extractor,代碼行數:33,代碼來源:JpegReader.java

示例8: addError

import com.drew.metadata.Metadata; //導入方法依賴的package包/類
protected void addError(@NotNull String errorMessage, final @NotNull Metadata metadata) {
    ErrorDirectory directory = metadata.getFirstDirectoryOfType(ErrorDirectory.class);
    if (directory == null) {
        metadata.addDirectory(new ErrorDirectory(errorMessage));
    } else {
        directory.addError(errorMessage);
    }
}
 
開發者ID:drewnoakes,項目名稱:metadata-extractor,代碼行數:9,代碼來源:BmpReader.java

示例9: extract

import com.drew.metadata.Metadata; //導入方法依賴的package包/類
/**
 * Performs the JFXX data extraction, adding found values to the specified
 * instance of {@link Metadata}.
 */
public void extract(@NotNull final RandomAccessReader reader, @NotNull final Metadata metadata)
{
    JfxxDirectory directory = new JfxxDirectory();
    metadata.addDirectory(directory);

    try {
        // For JFXX, the tag number is also the offset into the segment

        directory.setInt(JfxxDirectory.TAG_EXTENSION_CODE, reader.getUInt8(JfxxDirectory.TAG_EXTENSION_CODE));
    } catch (IOException me) {
        directory.addError(me.getMessage());
    }
}
 
開發者ID:drewnoakes,項目名稱:metadata-extractor,代碼行數:18,代碼來源:JfxxReader.java

示例10: HeifHandler

import com.drew.metadata.Metadata; //導入方法依賴的package包/類
public HeifHandler(Metadata metadata)
{
    this.metadata = metadata;
    this.directory = getDirectory();
    metadata.addDirectory(directory);
}
 
開發者ID:drewnoakes,項目名稱:metadata-extractor,代碼行數:7,代碼來源:HeifHandler.java

示例11: Mp4Handler

import com.drew.metadata.Metadata; //導入方法依賴的package包/類
public Mp4Handler(@NotNull Metadata metadata)
{
    this.metadata = metadata;
    this.directory = getDirectory();
    metadata.addDirectory(directory);
}
 
開發者ID:drewnoakes,項目名稱:metadata-extractor,代碼行數:7,代碼來源:Mp4Handler.java

示例12: QuickTimeHandler

import com.drew.metadata.Metadata; //導入方法依賴的package包/類
public QuickTimeHandler(@NotNull Metadata metadata)
{
    this.metadata = metadata;
    this.directory = getDirectory();
    metadata.addDirectory(directory);
}
 
開發者ID:drewnoakes,項目名稱:metadata-extractor,代碼行數:7,代碼來源:QuickTimeHandler.java

示例13: extract

import com.drew.metadata.Metadata; //導入方法依賴的package包/類
public void extract(@NotNull final RandomAccessReader reader, @NotNull final Metadata metadata, @Nullable Directory parentDirectory)
{
    // TODO review whether the 'tagPtr' values below really do require RandomAccessReader or whether SequentialReader may be used instead

    IccDirectory directory = new IccDirectory();

    if (parentDirectory != null)
        directory.setParent(parentDirectory);

    try {
        int profileByteCount = reader.getInt32(IccDirectory.TAG_PROFILE_BYTE_COUNT);
        directory.setInt(IccDirectory.TAG_PROFILE_BYTE_COUNT, profileByteCount);

        // For these tags, the int value of the tag is in fact it's offset within the buffer.
        set4ByteString(directory, IccDirectory.TAG_CMM_TYPE, reader);
        setInt32(directory, IccDirectory.TAG_PROFILE_VERSION, reader);
        set4ByteString(directory, IccDirectory.TAG_PROFILE_CLASS, reader);
        set4ByteString(directory, IccDirectory.TAG_COLOR_SPACE, reader);
        set4ByteString(directory, IccDirectory.TAG_PROFILE_CONNECTION_SPACE, reader);
        setDate(directory, IccDirectory.TAG_PROFILE_DATETIME, reader);
        set4ByteString(directory, IccDirectory.TAG_SIGNATURE, reader);
        set4ByteString(directory, IccDirectory.TAG_PLATFORM, reader);
        setInt32(directory, IccDirectory.TAG_CMM_FLAGS, reader);
        set4ByteString(directory, IccDirectory.TAG_DEVICE_MAKE, reader);

        int temp = reader.getInt32(IccDirectory.TAG_DEVICE_MODEL);
        if (temp != 0) {
            if (temp <= 0x20202020) {
                directory.setInt(IccDirectory.TAG_DEVICE_MODEL, temp);
            } else {
                directory.setString(IccDirectory.TAG_DEVICE_MODEL, getStringFromInt32(temp));
            }
        }

        setInt32(directory, IccDirectory.TAG_RENDERING_INTENT, reader);
        setInt64(directory, IccDirectory.TAG_DEVICE_ATTR, reader);

        float[] xyz = new float[]{
                reader.getS15Fixed16(IccDirectory.TAG_XYZ_VALUES),
                reader.getS15Fixed16(IccDirectory.TAG_XYZ_VALUES + 4),
                reader.getS15Fixed16(IccDirectory.TAG_XYZ_VALUES + 8)
        };
        directory.setObject(IccDirectory.TAG_XYZ_VALUES, xyz);

        // Process 'ICC tags'
        int tagCount = reader.getInt32(IccDirectory.TAG_TAG_COUNT);
        directory.setInt(IccDirectory.TAG_TAG_COUNT, tagCount);

        for (int i = 0; i < tagCount; i++) {
            int pos = IccDirectory.TAG_TAG_COUNT + 4 + i * 12;
            int tagType = reader.getInt32(pos);
            int tagPtr = reader.getInt32(pos + 4);
            int tagLen = reader.getInt32(pos + 8);
            byte[] b = reader.getBytes(tagPtr, tagLen);
            directory.setByteArray(tagType, b);
        }
    } catch (IOException ex) {
        directory.addError("Exception reading ICC profile: " + ex.getMessage());
    }

    metadata.addDirectory(directory);
}
 
開發者ID:drewnoakes,項目名稱:metadata-extractor,代碼行數:63,代碼來源:IccReader.java

示例14: extract

import com.drew.metadata.Metadata; //導入方法依賴的package包/類
public void extract(byte[] segmentBytes, Metadata metadata, JpegSegmentType segmentType)
{
    JpegDirectory directory = metadata.getFirstDirectoryOfType(JpegDirectory.class);
    if (directory == null) {
        ErrorDirectory errorDirectory = new ErrorDirectory();
        metadata.addDirectory(errorDirectory);
        errorDirectory.addError("DNL segment found without SOFx - illegal JPEG format");
        return;
    }

    SequentialReader reader = new SequentialByteArrayReader(segmentBytes);

    try {
        // Only set height from DNL if it's not already defined
        Integer i = directory.getInteger(JpegDirectory.TAG_IMAGE_HEIGHT);
        if (i == null || i == 0) {
            directory.setInt(JpegDirectory.TAG_IMAGE_HEIGHT, reader.getUInt16());
        }
    } catch (IOException ex) {
        directory.addError(ex.getMessage());
    }
}
 
開發者ID:drewnoakes,項目名稱:metadata-extractor,代碼行數:23,代碼來源:JpegDnlReader.java

示例15: AviRiffHandler

import com.drew.metadata.Metadata; //導入方法依賴的package包/類
public AviRiffHandler(@NotNull Metadata metadata)
{
    _directory = new AviDirectory();
    metadata.addDirectory(_directory);
}
 
開發者ID:drewnoakes,項目名稱:metadata-extractor,代碼行數:6,代碼來源:AviRiffHandler.java


注:本文中的com.drew.metadata.Metadata.addDirectory方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。