本文整理汇总了Java中com.drew.metadata.jpeg.JpegDirectory类的典型用法代码示例。如果您正苦于以下问题:Java JpegDirectory类的具体用法?Java JpegDirectory怎么用?Java JpegDirectory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JpegDirectory类属于com.drew.metadata.jpeg包,在下文中一共展示了JpegDirectory类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getHeight
import com.drew.metadata.jpeg.JpegDirectory; //导入依赖的package包/类
private Integer getHeight(final Metadata metadata) {
Integer value = null;
ExifSubIFDDirectory directory = metadata.getDirectory(ExifSubIFDDirectory.class);
if (directory != null && directory.containsTag(ExifSubIFDDirectory.TAG_EXIF_IMAGE_HEIGHT)) {
value = directory.getInteger(ExifSubIFDDirectory.TAG_EXIF_IMAGE_HEIGHT);
} else {
JpegDirectory dir = metadata.getDirectory(JpegDirectory.class);
if (dir != null && dir.containsTag(JpegDirectory.TAG_JPEG_IMAGE_HEIGHT)) {
value = dir.getInteger(JpegDirectory.TAG_JPEG_IMAGE_HEIGHT);
}
}
return value;
}
开发者ID:rizzow,项目名称:atombox-standalone,代码行数:14,代码来源:JpegImporter.java
示例2: testExtract_Height
import com.drew.metadata.jpeg.JpegDirectory; //导入依赖的package包/类
public void testExtract_Height() throws Exception
{
assertEquals(600, _directory.getInt(JpegDirectory.TAG_JPEG_IMAGE_HEIGHT));
}
开发者ID:ecologylab,项目名称:BigSemanticsJava,代码行数:5,代码来源:JpegReaderTest.java
示例3: testGetComponent
import com.drew.metadata.jpeg.JpegDirectory; //导入依赖的package包/类
public void testGetComponent() throws Exception
{
JpegComponent component1 = new JpegComponent(1, 2, 3);
JpegComponent component2 = new JpegComponent(1, 2, 3);
JpegComponent component3 = new JpegComponent(1, 2, 3);
JpegComponent component4 = new JpegComponent(1, 2, 3);
_directory.setObject(JpegDirectory.TAG_JPEG_COMPONENT_DATA_1, component1);
_directory.setObject(JpegDirectory.TAG_JPEG_COMPONENT_DATA_2, component2);
_directory.setObject(JpegDirectory.TAG_JPEG_COMPONENT_DATA_3, component3);
_directory.setObject(JpegDirectory.TAG_JPEG_COMPONENT_DATA_4, component4);
// component numbers are zero-indexed for this method
assertSame(component1, _directory.getComponent(0));
assertSame(component2, _directory.getComponent(1));
assertSame(component3, _directory.getComponent(2));
assertSame(component4, _directory.getComponent(3));
}
开发者ID:ecologylab,项目名称:BigSemanticsJava,代码行数:19,代码来源:JpegDirectoryTest.java
示例4: calculateJPEGSubsampling
import com.drew.metadata.jpeg.JpegDirectory; //导入依赖的package包/类
/**
* Calculates the J:a:b chroma subsampling notation from a {@link Metadata}
* instance generated from a JPEG image. If the non-luminance components
* have different subsampling values or the calculation is impossible,
* {@link Double#NaN} will be returned for all factors.
*
* @param metadata the {@link Metadata} instance from which to calculate.
* @return A {@link JPEGSubsamplingNotation} with the result.
*/
public static JPEGSubsamplingNotation calculateJPEGSubsampling(Metadata metadata) {
if (metadata == null) {
throw new NullPointerException("metadata cannot be null");
}
JpegDirectory directory = metadata.getFirstDirectoryOfType(JpegDirectory.class);
if (directory == null) {
return new JPEGSubsamplingNotation(Double.NaN, Double.NaN, Double.NaN);
}
return calculateJPEGSubsampling(directory);
}
开发者ID:DigitalMediaServer,项目名称:DigitalMediaServer,代码行数:22,代码来源:JPEGSubsamplingNotation.java
示例5: handle
import com.drew.metadata.jpeg.JpegDirectory; //导入依赖的package包/类
public void handle(Directory directory, Metadata metadata) throws MetadataException {
// The test TIFF has width and height stored as follows according to exiv2
//Exif.Image.ImageWidth Short 1 100
//Exif.Image.ImageLength Short 1 75
// and the values are found in "Thumbnail Image Width" (and Height) from Metadata Extractor
set(directory, metadata, ExifThumbnailDirectory.TAG_THUMBNAIL_IMAGE_WIDTH, Metadata.IMAGE_WIDTH);
set(directory, metadata, JpegDirectory.TAG_JPEG_IMAGE_WIDTH, Metadata.IMAGE_WIDTH);
set(directory, metadata, ExifThumbnailDirectory.TAG_THUMBNAIL_IMAGE_HEIGHT, Metadata.IMAGE_LENGTH);
set(directory, metadata, JpegDirectory.TAG_JPEG_IMAGE_HEIGHT, Metadata.IMAGE_LENGTH);
// Bits per sample, two methods of extracting, exif overrides jpeg
set(directory, metadata, JpegDirectory.TAG_JPEG_DATA_PRECISION, Metadata.BITS_PER_SAMPLE);
set(directory, metadata, ExifSubIFDDirectory.TAG_BITS_PER_SAMPLE, Metadata.BITS_PER_SAMPLE);
// Straightforward
set(directory, metadata, ExifSubIFDDirectory.TAG_SAMPLES_PER_PIXEL, Metadata.SAMPLES_PER_PIXEL);
}
开发者ID:kolbasa,项目名称:OCRaptor,代码行数:16,代码来源:ImageMetadataExtractor.java
示例6: getPrecision
import com.drew.metadata.jpeg.JpegDirectory; //导入依赖的package包/类
private Integer getPrecision(final Metadata metadata) {
Integer value = null;
JpegDirectory directory = metadata.getDirectory(JpegDirectory.class);
if (directory != null && directory.containsTag(JpegDirectory.TAG_JPEG_DATA_PRECISION)) {
value = directory.getInteger(JpegDirectory.TAG_JPEG_DATA_PRECISION);
}
return value;
}
开发者ID:rizzow,项目名称:atombox-standalone,代码行数:9,代码来源:JpegImporter.java
示例7: getChannelCount
import com.drew.metadata.jpeg.JpegDirectory; //导入依赖的package包/类
private Integer getChannelCount(final Metadata metadata) {
Integer value = null;
JpegDirectory directory = metadata.getDirectory(JpegDirectory.class);
if (directory != null && directory.containsTag(JpegDirectory.TAG_JPEG_NUMBER_OF_COMPONENTS)) {
value = directory.getInteger(JpegDirectory.TAG_JPEG_NUMBER_OF_COMPONENTS);
}
return value;
}
开发者ID:rizzow,项目名称:atombox-standalone,代码行数:9,代码来源:JpegImporter.java
示例8: setUp
import com.drew.metadata.jpeg.JpegDirectory; //导入依赖的package包/类
public void setUp() throws JpegProcessingException, FileNotFoundException
{
// use a known testing image
File jpegFile = new File("Source/com/drew/metadata/jpeg/test/simple.jpg");
JpegReader reader = new JpegReader(jpegFile);
Metadata metadata = reader.extract();
assertTrue(metadata.containsDirectory(JpegDirectory.class));
_directory = (JpegDirectory)metadata.getDirectory(JpegDirectory.class);
}
开发者ID:ecologylab,项目名称:BigSemanticsJava,代码行数:10,代码来源:JpegReaderTest.java
示例9: testComponentData1
import com.drew.metadata.jpeg.JpegDirectory; //导入依赖的package包/类
public void testComponentData1() throws Exception
{
JpegComponent component = (JpegComponent)_directory.getObject(JpegDirectory.TAG_JPEG_COMPONENT_DATA_1);
assertEquals("Y", component.getComponentName());
assertEquals(1, component.getComponentId());
assertEquals(0, component.getQuantizationTableNumber());
assertEquals(2, component.getHorizontalSamplingFactor());
assertEquals(2, component.getVerticalSamplingFactor());
}
开发者ID:ecologylab,项目名称:BigSemanticsJava,代码行数:10,代码来源:JpegReaderTest.java
示例10: testComponentData2
import com.drew.metadata.jpeg.JpegDirectory; //导入依赖的package包/类
public void testComponentData2() throws Exception
{
JpegComponent component = (JpegComponent)_directory.getObject(JpegDirectory.TAG_JPEG_COMPONENT_DATA_2);
assertEquals("Cb", component.getComponentName());
assertEquals(2, component.getComponentId());
assertEquals(1, component.getQuantizationTableNumber());
assertEquals(1, component.getHorizontalSamplingFactor());
assertEquals(1, component.getVerticalSamplingFactor());
assertEquals("Cb component: Quantization table 1, Sampling factors 1 horiz/1 vert", _directory.getDescription(JpegDirectory.TAG_JPEG_COMPONENT_DATA_2));
}
开发者ID:ecologylab,项目名称:BigSemanticsJava,代码行数:11,代码来源:JpegReaderTest.java
示例11: testComponentData3
import com.drew.metadata.jpeg.JpegDirectory; //导入依赖的package包/类
public void testComponentData3() throws Exception
{
JpegComponent component = (JpegComponent)_directory.getObject(JpegDirectory.TAG_JPEG_COMPONENT_DATA_3);
assertEquals("Cr", component.getComponentName());
assertEquals(3, component.getComponentId());
assertEquals(1, component.getQuantizationTableNumber());
assertEquals(1, component.getHorizontalSamplingFactor());
assertEquals(1, component.getVerticalSamplingFactor());
assertEquals("Cr component: Quantization table 1, Sampling factors 1 horiz/1 vert", _directory.getDescription(JpegDirectory.TAG_JPEG_COMPONENT_DATA_3));
}
开发者ID:ecologylab,项目名称:BigSemanticsJava,代码行数:11,代码来源:JpegReaderTest.java
示例12: testGetComponentDescription
import com.drew.metadata.jpeg.JpegDirectory; //导入依赖的package包/类
public void testGetComponentDescription() throws MetadataException
{
JpegComponent component1 = new JpegComponent(1, 0x22, 0);
_directory.setObject(JpegDirectory.TAG_JPEG_COMPONENT_DATA_1, component1);
assertEquals("Y component: Quantization table 0, Sampling factors 2 horiz/2 vert", _directory.getDescription(JpegDirectory.TAG_JPEG_COMPONENT_DATA_1));
assertEquals("Y component: Quantization table 0, Sampling factors 2 horiz/2 vert", _descriptor.getComponentDataDescription(0));
}
开发者ID:ecologylab,项目名称:BigSemanticsJava,代码行数:8,代码来源:JpegDescriptorTest.java
示例13: readImageInformation
import com.drew.metadata.jpeg.JpegDirectory; //导入依赖的package包/类
public static ImageInformation readImageInformation(File imageFile) throws IOException, MetadataException, ImageProcessingException {
Metadata metadata = ImageMetadataReader.readMetadata(imageFile);
ExifDirectoryBase exifDirectoryBase = metadata.getFirstDirectoryOfType(ExifDirectoryBase.class);
JpegDirectory jpegDirectory = metadata.getFirstDirectoryOfType(JpegDirectory.class);
IptcDirectory ipTCdirectory = metadata.getFirstDirectoryOfType(IptcDirectory.class);
int orientation = 1;
Date dateTaken = null;
String uniqueID = "";
if( exifDirectoryBase != null )
{
if( exifDirectoryBase.containsTag(ExifIFD0Directory.TAG_ORIENTATION))
orientation = exifDirectoryBase.getInt(ExifIFD0Directory.TAG_ORIENTATION);
}
ExifSubIFDDirectory exifSubIFDDirectory = metadata.getFirstDirectoryOfType(ExifSubIFDDirectory.class);
if( exifSubIFDDirectory != null )
{
if( exifSubIFDDirectory.containsTag( ExifDirectoryBase.TAG_IMAGE_UNIQUE_ID ))
uniqueID = exifSubIFDDirectory.getString(ExifDirectoryBase.TAG_IMAGE_UNIQUE_ID);
if( exifSubIFDDirectory.containsTag( ExifDirectoryBase.TAG_DATETIME ))
dateTaken = exifSubIFDDirectory.getDate( ExifDirectoryBase.TAG_DATETIME );
if( dateTaken == null && exifSubIFDDirectory.containsTag( ExifIFD0Directory.TAG_DATETIME_ORIGINAL ))
dateTaken = exifSubIFDDirectory.getDate(ExifDirectoryBase.TAG_DATETIME_ORIGINAL);
if( dateTaken == null && exifSubIFDDirectory.containsTag( ExifIFD0Directory.TAG_DATETIME_DIGITIZED ))
dateTaken = exifSubIFDDirectory.getDate(ExifDirectoryBase.TAG_DATETIME_DIGITIZED);
if( dateTaken == null )
dateTaken = getCreationTime( imageFile );
}
boolean hasDeleteTag = false;
if( ipTCdirectory != null && ipTCdirectory.getKeywords() != null )
{
if( containsCaseInsensitive( ipTCdirectory.getKeywords(), "delete") )
hasDeleteTag = true;
}
int width = jpegDirectory.getImageWidth();
int height = jpegDirectory.getImageHeight();
return new ImageInformation(orientation, width, height, hasDeleteTag, uniqueID, dateTaken );
}
开发者ID:Dotosoft,项目名称:dotoquiz-tools,代码行数:51,代码来源:ImageInformation.java
示例14: supports
import com.drew.metadata.jpeg.JpegDirectory; //导入依赖的package包/类
public boolean supports(Class<? extends Directory> directoryType) {
return directoryType == JpegDirectory.class ||
directoryType == ExifSubIFDDirectory.class ||
directoryType == ExifThumbnailDirectory.class ||
directoryType == ExifIFD0Directory.class;
}
开发者ID:kolbasa,项目名称:OCRaptor,代码行数:7,代码来源:ImageMetadataExtractor.java
示例15: extractMetadataFromJpegSegmentReader
import com.drew.metadata.jpeg.JpegDirectory; //导入依赖的package包/类
@NotNull
public static Metadata extractMetadataFromJpegSegmentReader(@NotNull JpegSegmentData segmentReader)
{
final Metadata metadata = new Metadata();
// Loop through looking for all SOFn segments. When we find one, we know what type of compression
// was used for the JPEG, and we can process the JPEG metadata in the segment too.
for (byte i = 0; i < 16; i++) {
// There are no SOF4 or SOF12 segments, so don't bother
if (i == 4 || i == 12)
continue;
// Should never have more than one SOFn for a given 'n'.
byte[] jpegSegment = segmentReader.getSegment((byte)(JpegSegmentReader.SEGMENT_SOF0 + i));
if (jpegSegment == null)
continue;
JpegDirectory directory = metadata.getOrCreateDirectory(JpegDirectory.class);
directory.setInt(JpegDirectory.TAG_JPEG_COMPRESSION_TYPE, i);
new JpegReader().extract(new ByteArrayReader(jpegSegment), metadata);
break;
}
// There should never be more than one COM segment.
byte[] comSegment = segmentReader.getSegment(JpegSegmentReader.SEGMENT_COM);
if (comSegment != null)
new JpegCommentReader().extract(new ByteArrayReader(comSegment), metadata);
// Loop through all APP0 segments, looking for a JFIF segment.
for (byte[] app0Segment : segmentReader.getSegments(JpegSegmentReader.SEGMENT_APP0)) {
if (app0Segment.length > 3 && new String(app0Segment, 0, 4).equals("JFIF"))
new JfifReader().extract(new ByteArrayReader(app0Segment), metadata);
}
// Loop through all APP1 segments, checking the leading bytes to identify the format of each.
for (byte[] app1Segment : segmentReader.getSegments(JpegSegmentReader.SEGMENT_APP1)) {
if (app1Segment.length > 3 && "EXIF".equalsIgnoreCase(new String(app1Segment, 0, 4)))
new ExifReader().extract(new ByteArrayReader(app1Segment), metadata);
if (app1Segment.length > 27 && "http://ns.adobe.com/xap/1.0/".equalsIgnoreCase(new String(app1Segment, 0, 28)))
new XmpReader().extract(new ByteArrayReader(app1Segment), metadata);
}
// Loop through all APP2 segments, looking for something we can process.
for (byte[] app2Segment : segmentReader.getSegments(JpegSegmentReader.SEGMENT_APP2)) {
if (app2Segment.length > 10 && new String(app2Segment, 0, 11).equalsIgnoreCase("ICC_PROFILE")) {
byte[] icc = new byte[app2Segment.length-14];
System.arraycopy(app2Segment, 14, icc, 0, app2Segment.length-14);
new IccReader().extract(new ByteArrayReader(icc), metadata);
}
}
// Loop through all APPD segments, checking the leading bytes to identify the format of each.
for (byte[] appdSegment : segmentReader.getSegments(JpegSegmentReader.SEGMENT_APPD)) {
if (appdSegment.length > 12 && "Photoshop 3.0".compareTo(new String(appdSegment, 0, 13))==0) {
new PhotoshopReader().extract(new ByteArrayReader(appdSegment), metadata);
} else {
// TODO might be able to check for a leading 0x1c02 for IPTC data...
new IptcReader().extract(new ByteArrayReader(appdSegment), metadata);
}
}
// Loop through all APPE segments, checking the leading bytes to identify the format of each.
for (byte[] appeSegment : segmentReader.getSegments(JpegSegmentReader.SEGMENT_APPE)) {
if (appeSegment.length == 12 && "Adobe".compareTo(new String(appeSegment, 0, 5))==0) {
new AdobeJpegReader().extract(new ByteArrayReader(appeSegment), metadata);
}
}
return metadata;
}
开发者ID:mxbossard,项目名称:metadata-extractor-osgi,代码行数:70,代码来源:JpegMetadataReader.java
示例16: testExtract_Width
import com.drew.metadata.jpeg.JpegDirectory; //导入依赖的package包/类
public void testExtract_Width() throws Exception
{
assertEquals(800, _directory.getInt(JpegDirectory.TAG_JPEG_IMAGE_WIDTH));
}
开发者ID:ecologylab,项目名称:BigSemanticsJava,代码行数:5,代码来源:JpegReaderTest.java
示例17: testExtract_DataPrecision
import com.drew.metadata.jpeg.JpegDirectory; //导入依赖的package包/类
public void testExtract_DataPrecision() throws Exception
{
assertEquals(8, _directory.getInt(JpegDirectory.TAG_JPEG_DATA_PRECISION));
}
开发者ID:ecologylab,项目名称:BigSemanticsJava,代码行数:5,代码来源:JpegReaderTest.java
示例18: testExtract_NumberOfComponents
import com.drew.metadata.jpeg.JpegDirectory; //导入依赖的package包/类
public void testExtract_NumberOfComponents() throws Exception
{
assertEquals(3, _directory.getInt(JpegDirectory.TAG_JPEG_NUMBER_OF_COMPONENTS));
}
开发者ID:ecologylab,项目名称:BigSemanticsJava,代码行数:5,代码来源:JpegReaderTest.java
示例19: setUp
import com.drew.metadata.jpeg.JpegDirectory; //导入依赖的package包/类
public void setUp() throws Exception
{
_directory = new JpegDirectory();
_descriptor = new JpegDescriptor(_directory);
}
开发者ID:ecologylab,项目名称:BigSemanticsJava,代码行数:6,代码来源:JpegDescriptorTest.java
示例20: testGetImageWidthDescription
import com.drew.metadata.jpeg.JpegDirectory; //导入依赖的package包/类
public void testGetImageWidthDescription() throws Exception
{
_directory.setInt(JpegDirectory.TAG_JPEG_IMAGE_WIDTH, 123);
assertEquals("123 pixels", _descriptor.getImageWidthDescription());
assertEquals("123 pixels", _directory.getDescription(JpegDirectory.TAG_JPEG_IMAGE_WIDTH));
}
开发者ID:ecologylab,项目名称:BigSemanticsJava,代码行数:7,代码来源:JpegDescriptorTest.java
注:本文中的com.drew.metadata.jpeg.JpegDirectory类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论