本文整理汇总了Java中com.drew.imaging.tiff.TiffMetadataReader.readMetadata方法的典型用法代码示例。如果您正苦于以下问题:Java TiffMetadataReader.readMetadata方法的具体用法?Java TiffMetadataReader.readMetadata怎么用?Java TiffMetadataReader.readMetadata使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.drew.imaging.tiff.TiffMetadataReader
的用法示例。
在下文中一共展示了TiffMetadataReader.readMetadata方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readMetadata
import com.drew.imaging.tiff.TiffMetadataReader; //导入方法依赖的package包/类
private static Metadata readMetadata(BufferedInputStream inputStream, File file, int magicNumber) throws ImageProcessingException
{
if ((magicNumber & JPEG_FILE_MAGIC_NUMBER)==JPEG_FILE_MAGIC_NUMBER) {
if (inputStream!=null)
return JpegMetadataReader.readMetadata(inputStream);
else
return JpegMetadataReader.readMetadata(file);
} else if (magicNumber==INTEL_TIFF_MAGIC_NUMBER || magicNumber==MOTOROLLA_TIFF_MAGIC_NUMBER) {
if (inputStream!=null)
return TiffMetadataReader.readMetadata(inputStream);
else
return TiffMetadataReader.readMetadata(file);
} else {
throw new ImageProcessingException("File is not the correct format");
}
}
示例2: parseTiff
import com.drew.imaging.tiff.TiffMetadataReader; //导入方法依赖的package包/类
public void parseTiff(File file)
throws IOException, SAXException, TikaException {
try {
com.drew.metadata.Metadata tiffMetadata = TiffMetadataReader.readMetadata(file);
handle(tiffMetadata);
} catch (MetadataException e) {
throw new TikaException("Can't read TIFF metadata", e);
}
}
示例3: readMetadata
import com.drew.imaging.tiff.TiffMetadataReader; //导入方法依赖的package包/类
@NotNull
private static Metadata readMetadata(@Nullable BufferedInputStream inputStream, @Nullable File file, int magicNumber, boolean waitForBytes) throws ImageProcessingException, IOException
{
assert(file!=null ^ inputStream!=null);
// This covers all JPEG files
if ((magicNumber & JPEG_FILE_MAGIC_NUMBER) == JPEG_FILE_MAGIC_NUMBER) {
if (inputStream != null)
return JpegMetadataReader.readMetadata(inputStream, waitForBytes);
else
return JpegMetadataReader.readMetadata(file);
}
// This covers all TIFF and camera RAW files
if (magicNumber == INTEL_TIFF_MAGIC_NUMBER || magicNumber == MOTOROLA_TIFF_MAGIC_NUMBER) {
if (inputStream != null)
return TiffMetadataReader.readMetadata(inputStream, waitForBytes);
else
return TiffMetadataReader.readMetadata(file);
}
// This covers PSD files
// TODO we should really check all 4 bytes of the PSD magic number
if (magicNumber == PSD_MAGIC_NUMBER) {
if (inputStream != null)
return PsdMetadataReader.readMetadata(inputStream, waitForBytes);
else
return PsdMetadataReader.readMetadata(file);
}
throw new ImageProcessingException("File format is not supported");
}
示例4: readMetadata
import com.drew.imaging.tiff.TiffMetadataReader; //导入方法依赖的package包/类
/**
* Reads metadata from an {@link InputStream} of known length and file type.
*
* @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.
* @param fileType the file type of the data stream.
* @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, final FileType fileType) throws IOException, ImageProcessingException
{
switch (fileType) {
case Jpeg:
return JpegMetadataReader.readMetadata(inputStream);
case Tiff:
case Arw:
case Cr2:
case Nef:
case Orf:
case Rw2:
return TiffMetadataReader.readMetadata(new RandomAccessStreamReader(inputStream, RandomAccessStreamReader.DEFAULT_CHUNK_LENGTH, streamLength));
case Psd:
return PsdMetadataReader.readMetadata(inputStream);
case Png:
return PngMetadataReader.readMetadata(inputStream);
case Bmp:
return BmpMetadataReader.readMetadata(inputStream);
case Gif:
return GifMetadataReader.readMetadata(inputStream);
case Ico:
return IcoMetadataReader.readMetadata(inputStream);
case Pcx:
return PcxMetadataReader.readMetadata(inputStream);
case WebP:
return WebpMetadataReader.readMetadata(inputStream);
case Raf:
return RafMetadataReader.readMetadata(inputStream);
case Avi:
return AviMetadataReader.readMetadata(inputStream);
case Wav:
return WavMetadataReader.readMetadata(inputStream);
case Mov:
return QuickTimeMetadataReader.readMetadata(inputStream);
case Mp4:
return Mp4MetadataReader.readMetadata(inputStream);
case Eps:
return EpsMetadataReader.readMetadata(inputStream);
case Heif:
return HeifMetadataReader.readMetadata(inputStream);
case Unknown:
throw new ImageProcessingException("File format could not be determined");
default:
return new Metadata();
}
}
示例5: readMetadata
import com.drew.imaging.tiff.TiffMetadataReader; //导入方法依赖的package包/类
/**
* Reads metadata from an {@link InputStream}.
* <p/>
* The file type is determined by inspecting the leading bytes of the stream, and parsing of the file
* is delegated to one of:
* <ul>
* <li>{@link JpegMetadataReader} for JPEG files</li>
* <li>{@link TiffMetadataReader} for TIFF and (most) RAW files</li>
* <li>{@link PsdMetadataReader} for Photoshop files</li>
* <li>{@link PngMetadataReader} for PNG files</li>
* <li>{@link BmpMetadataReader} for BMP files</li>
* <li>{@link GifMetadataReader} for GIF files</li>
* </ul>
*
* @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.
* @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) throws ImageProcessingException, IOException
{
InputStream bufferedInputStream = inputStream instanceof BufferedInputStream ? inputStream : new BufferedInputStream(inputStream);
int magicNumber = peekMagicNumber(bufferedInputStream);
if (magicNumber == -1)
throw new ImageProcessingException("Could not determine file's magic number.");
// This covers all JPEG files
if ((magicNumber & JPEG_FILE_MAGIC_NUMBER) == JPEG_FILE_MAGIC_NUMBER) {
return JpegMetadataReader.readMetadata(bufferedInputStream);
}
// This covers all TIFF and camera RAW files
if (magicNumber == INTEL_TIFF_MAGIC_NUMBER || magicNumber == MOTOROLA_TIFF_MAGIC_NUMBER) {
return TiffMetadataReader.readMetadata(bufferedInputStream);
}
// This covers PSD files
// TODO we should really check all 4 bytes of the PSD magic number
if (magicNumber == PSD_MAGIC_NUMBER) {
return PsdMetadataReader.readMetadata(bufferedInputStream);
}
// This covers BMP files
if (magicNumber == PNG_MAGIC_NUMBER) {
return PngMetadataReader.readMetadata(bufferedInputStream);
}
// This covers BMP files
if (magicNumber == BMP_MAGIC_NUMBER) {
return BmpMetadataReader.readMetadata(bufferedInputStream);
}
// This covers GIF files
if (magicNumber == GIF_MAGIC_NUMBER) {
return GifMetadataReader.readMetadata(bufferedInputStream);
}
throw new ImageProcessingException("File format is not supported");
}