• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java MetadataException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.drew.metadata.MetadataException的典型用法代码示例。如果您正苦于以下问题:Java MetadataException类的具体用法?Java MetadataException怎么用?Java MetadataException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



MetadataException类属于com.drew.metadata包,在下文中一共展示了MetadataException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: handle

import com.drew.metadata.MetadataException; //导入依赖的package包/类
public void handle(Directory directory, Metadata metadata)
        throws MetadataException {
    if (directory.getTags() != null) {
        Iterator<?> tags = directory.getTags().iterator();
        while (tags.hasNext()) {
            Tag tag = (Tag) tags.next();
            String name = tag.getTagName();
            if (!MetadataFields.isMetadataField(name) && tag.getDescription() != null) {
                  String value = tag.getDescription().trim();
                  if (Boolean.TRUE.toString().equalsIgnoreCase(value)) {
                      value = Boolean.TRUE.toString();
                  } else if (Boolean.FALSE.toString().equalsIgnoreCase(value)) {
                      value = Boolean.FALSE.toString();
                  }
                  metadata.set(name, value);
            }
        }
    }
}
 
开发者ID:kolbasa,项目名称:OCRaptor,代码行数:20,代码来源:ImageMetadataExtractor.java


示例2: fixOrientation

import com.drew.metadata.MetadataException; //导入依赖的package包/类
public void fixOrientation() throws ImageMutationFailedException {
    try {
        Metadata metadata = originalImageMetaData();

        ExifIFD0Directory exifIFD0Directory = metadata.getFirstDirectoryOfType(ExifIFD0Directory.class);
        if (exifIFD0Directory == null) {
            return;
        } else if (exifIFD0Directory.containsTag(ExifIFD0Directory.TAG_ORIENTATION)) {
            int exifOrientation = exifIFD0Directory.getInt(ExifIFD0Directory.TAG_ORIENTATION);
            if(exifOrientation != 1) {
                rotate(exifOrientation);
                exifIFD0Directory.setInt(ExifIFD0Directory.TAG_ORIENTATION, 1);
            }
        }
    } catch (ImageProcessingException | IOException | MetadataException e) {
        throw new ImageMutationFailedException("failed to fix orientation", e);
    }
}
 
开发者ID:jonathan68,项目名称:react-native-camera,代码行数:19,代码来源:MutableImage.java


示例3: parseExifOrientation

import com.drew.metadata.MetadataException; //导入依赖的package包/类
/**
 * Tries to parse {@link ExifOrientation} from the given metadata. If it
 * fails, {@code defaultOrientation} is returned.
 *
 * @param metadata the {@link Metadata} to parse.
 * @param defaultOrientation the default to return if parsing fails.
 * @return The parsed {@link ExifOrientation} or {@code defaultOrientation}.
 */
public static ExifOrientation parseExifOrientation(Metadata metadata, ExifOrientation defaultOrientation) {
	if (metadata == null) {
		return defaultOrientation;
	}
	try {
		for (Directory directory : metadata.getDirectories()) {
			if (directory instanceof ExifIFD0Directory) {
				if (((ExifIFD0Directory) directory).containsTag(ExifIFD0Directory.TAG_ORIENTATION)) {
					return ExifOrientation.typeOf(((ExifIFD0Directory) directory).getInt(ExifIFD0Directory.TAG_ORIENTATION));
				}
			}
		}
	} catch (MetadataException e) {
		return defaultOrientation;
	}
	return defaultOrientation;
}
 
开发者ID:DigitalMediaServer,项目名称:DigitalMediaServer,代码行数:26,代码来源:ImagesUtil.java


示例4: handleExifIFD0Directory

import com.drew.metadata.MetadataException; //导入依赖的package包/类
private void handleExifIFD0Directory(MetaData metaData, Directory directory) throws MetadataException{
	
	metaData.put(Image.MetaName.Make, getStringValue(directory, ExifIFD0Directory.TAG_MAKE));
	metaData.put(Image.MetaName.Model, getStringValue(directory, ExifIFD0Directory.TAG_MODEL));
	metaData.put(Image.MetaName.Software, getStringValue(directory, ExifIFD0Directory.TAG_SOFTWARE));

	// Date/Time Original overrides value from ExifDirectory.TAG_DATETIME
	// Unless we have GPS time we don't know the time zone so date must be set
	// as ISO 8601 datetime without timezone suffix (no Z or +/-)
	if (directory.containsTag(ExifIFD0Directory.TAG_DATETIME)) {
		metaData.put(Image.MetaName.DateTimeOriginal, getDateValue(directory, ExifIFD0Directory.TAG_DATETIME));
	}		

	if (directory.containsTag(ExifIFD0Directory.TAG_ORIENTATION)){
		Integer val = getIntValue(directory, ExifIFD0Directory.TAG_ORIENTATION);
		metaData.put(Image.MetaName.Orientation, translateOrientation(val));
	}

}
 
开发者ID:ivarptr,项目名称:clobaframe,代码行数:20,代码来源:ExifMetaDataPaser.java


示例5: getOrientation

import com.drew.metadata.MetadataException; //导入依赖的package包/类
private static int getOrientation(BufferedInputStream bis) throws IOException {
	try {
		Metadata metadata = ImageMetadataReader.readMetadata(bis);
		Directory directory = metadata.getFirstDirectoryOfType(ExifIFD0Directory.class);
		if (directory != null) {
			return directory.getInt(ExifIFD0Directory.TAG_ORIENTATION);
		}
		return 1;
	} catch (MetadataException | ImageProcessingException me) {
		return 1;
	}
}
 
开发者ID:oglimmer,项目名称:lunchy,代码行数:13,代码来源:ImageScaler.java


示例6: extractThumbnail

import com.drew.metadata.MetadataException; //导入依赖的package包/类
/**
 * Extracts from the EXIF meta-data the thumbnail registered with the picture.
 * If this thumbnail does not exists, creates one from the image data.
 * @param ed the EXIF meta-data
 * @param f the file containing the image
 * @return the thumbnail image or null if the thumbnail image could not be created
 */
private ImageIcon extractThumbnail(ExifDirectory ed, File f) {
	try {
		if (ed.containsThumbnail()) {
			ImageIcon thumbnail = new ImageIcon(ed.getThumbnailData());
			int actWidth = m_thumbnails.getFixedCellWidth();
			int shdWidth = thumbnail.getIconWidth() + 10;
			if (actWidth < shdWidth) m_thumbnails.setFixedCellWidth(shdWidth);
			int actHeight = m_thumbnails.getFixedCellHeight();
			int shdHeight = thumbnail.getIconHeight() + 30;
			if (actHeight < shdHeight) m_thumbnails.setFixedCellHeight(shdHeight);
			return thumbnail;
		}
	}
	catch (MetadataException me) {
		// Nothing to do here
	}
	return createThumbnail(ed,f);
}
 
开发者ID:geberle,项目名称:PhotMan,代码行数:26,代码来源:PhotManFrame.java


示例7: writeThumbnail

import com.drew.metadata.MetadataException; //导入依赖的package包/类
public void writeThumbnail(@NotNull String filename) throws MetadataException, IOException
{
    byte[] data = _thumbnailData;

    if (data == null)
        throw new MetadataException("No thumbnail data exists.");

    FileOutputStream stream = null;
    try {
        stream = new FileOutputStream(filename);
        stream.write(data);
    } finally {
        if (stream != null)
            stream.close();
    }
}
 
开发者ID:byronb92,项目名称:ImageEXIFExtraction,代码行数:17,代码来源:ExifThumbnailDirectory.java


示例8: testResolution

import com.drew.metadata.MetadataException; //导入依赖的package包/类
@Test
public void testResolution() throws JpegProcessingException, IOException, MetadataException
{
    Metadata metadata = ExifReaderTest.processBytes("Tests/Data/withUncompressedRGBThumbnail.jpg.app1");

    ExifThumbnailDirectory thumbnailDirectory = metadata.getDirectory(ExifThumbnailDirectory.class);
    assertNotNull(thumbnailDirectory);
    assertEquals(72, thumbnailDirectory.getInt(ExifThumbnailDirectory.TAG_X_RESOLUTION));
    
    ExifIFD0Directory exifIFD0Directory = metadata.getDirectory(ExifIFD0Directory.class);
    assertNotNull(exifIFD0Directory);
    assertEquals(216, exifIFD0Directory.getInt(ExifIFD0Directory.TAG_X_RESOLUTION));
}
 
开发者ID:byronb92,项目名称:ImageEXIFExtraction,代码行数:14,代码来源:ExifDirectoryTest.java


示例9: getSubjectDistanceRangeDescription

import com.drew.metadata.MetadataException; //导入依赖的package包/类
public String getSubjectDistanceRangeDescription() throws MetadataException
{
    if (!_directory.containsTag(ExifDirectory.TAG_SUBJECT_DISTANCE_RANGE)) return null;
    switch (_directory.getInt(ExifDirectory.TAG_SUBJECT_DISTANCE_RANGE)) {
        case 0:
            return "Unknown";
        case 1:
            return "Macro";
        case 2:
            return "Close view";
        case 3:
            return "Distant view";
        default:
            return "Unknown (" + _directory.getInt(ExifDirectory.TAG_SUBJECT_DISTANCE_RANGE) + ")";
    }
}
 
开发者ID:ecologylab,项目名称:BigSemanticsJava,代码行数:17,代码来源:ExifDescriptor.java


示例10: testResolution

import com.drew.metadata.MetadataException; //导入依赖的package包/类
@Test
public void testResolution() throws JpegProcessingException, IOException, MetadataException
{
    File file = new File("Tests/com/drew/metadata/exif/withUncompressedRGBThumbnail.jpg");
    Metadata metadata = JpegMetadataReader.readMetadata(file);

    ExifThumbnailDirectory thumbnailDirectory = metadata.getDirectory(ExifThumbnailDirectory.class);
    Assert.assertNotNull(thumbnailDirectory);
    Assert.assertEquals(72, thumbnailDirectory.getInt(ExifThumbnailDirectory.TAG_X_RESOLUTION));
    
    ExifIFD0Directory exifIFD0Directory = metadata.getDirectory(ExifIFD0Directory.class);
    Assert.assertNotNull(exifIFD0Directory);
    Assert.assertEquals(216, exifIFD0Directory.getInt(ExifIFD0Directory.TAG_X_RESOLUTION));
}
 
开发者ID:mxbossard,项目名称:metadata-extractor-osgi,代码行数:15,代码来源:ExifDirectoryTest.java


示例11: getDateValue

import com.drew.metadata.MetadataException; //导入依赖的package包/类
/**
 * Get a Date type value out of the exif dir.
 * 
 * @param dir
 * @return
 */
public Date getDateValue(com.drew.metadata.Directory dir)
{
	Date result	= null;
	if (dir.containsTag(exifTag))
		try
		{
			result			= dir.getDate(exifTag);
		}
		catch (MetadataException e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	return result;
}
 
开发者ID:ecologylab,项目名称:BigSemanticsJava,代码行数:22,代码来源:MetadataExifFeature.java


示例12: getComponentDataDescription

import com.drew.metadata.MetadataException; //导入依赖的package包/类
public String getComponentDataDescription(int componentNumber) throws MetadataException
{
    JpegComponent component = ((JpegDirectory)_directory).getComponent(componentNumber);

    if (component==null)
        throw new MetadataException("No Jpeg component exists with number " + componentNumber);

    StringBuffer sb = new StringBuffer();
    sb.append(component.getComponentName());
    sb.append(" component: Quantization table ");
    sb.append(component.getQuantizationTableNumber());
    sb.append(", Sampling factors ");
    sb.append(component.getHorizontalSamplingFactor());
    sb.append(" horiz/");
    sb.append(component.getVerticalSamplingFactor());
    sb.append(" vert");
    return sb.toString();
}
 
开发者ID:ecologylab,项目名称:BigSemanticsJava,代码行数:19,代码来源:JpegDescriptor.java


示例13: getComponentName

import com.drew.metadata.MetadataException; //导入依赖的package包/类
/**
 * Returns the component name (one of: Y, Cb, Cr, I, or Q)
 * @return the component name
 * @throws MetadataException if the component id is not known
 */
public String getComponentName() throws MetadataException
{
    switch (_componentId)
    {
        case 1:
            return "Y";
        case 2:
            return "Cb";
        case 3:
            return "Cr";
        case 4:
            return "I";
        case 5:
            return "Q";
    }

    throw new MetadataException("Unsupported component id: " + _componentId);
}
 
开发者ID:ecologylab,项目名称:BigSemanticsJava,代码行数:24,代码来源:JpegComponent.java


示例14: getOrientationDescription

import com.drew.metadata.MetadataException; //导入依赖的package包/类
public String getOrientationDescription() throws MetadataException
{
    if (!_directory.containsTag(ExifDirectory.TAG_ORIENTATION)) return null;
    int orientation = _directory.getInt(ExifDirectory.TAG_ORIENTATION);
    switch (orientation) {
        case 1: return "Top, left side (Horizontal / normal)";
        case 2: return "Top, right side (Mirror horizontal)";
        case 3: return "Bottom, right side (Rotate 180)";
        case 4: return "Bottom, left side (Mirror vertical)";
        case 5: return "Left side, top (Mirror horizontal and rotate 270 CW)";
        case 6: return "Right side, top (Rotate 90 CW)";
        case 7: return "Right side, bottom (Mirror horizontal and rotate 90 CW)";
        case 8: return "Left side, bottom (Rotate 270 CW)";
        default:
            return String.valueOf(orientation);
    }
}
 
开发者ID:ecologylab,项目名称:BigSemanticsJava,代码行数:18,代码来源:ExifDescriptor.java


示例15: getIsoSensitivityDescription

import com.drew.metadata.MetadataException; //导入依赖的package包/类
public String getIsoSensitivityDescription() throws MetadataException
{
    if (!_directory.containsTag(CasioType2MakernoteDirectory.TAG_CASIO_TYPE2_ISO_SENSITIVITY)) return null;
    int value = _directory.getInt(CasioType2MakernoteDirectory.TAG_CASIO_TYPE2_ISO_SENSITIVITY);
    switch (value) {
        case 3:
            return "50";
        case 4:
            return "64";
        case 6:
            return "100";
        case 9:
            return "200";
        default:
            return "Unknown (" + value + ")";
    }
}
 
开发者ID:ecologylab,项目名称:BigSemanticsJava,代码行数:18,代码来源:CasioType2MakernoteDescriptor.java


示例16: getContinuousDriveModeDescription

import com.drew.metadata.MetadataException; //导入依赖的package包/类
public String getContinuousDriveModeDescription() throws MetadataException
{
    if (!_directory.containsTag(CanonMakernoteDirectory.TAG_CANON_STATE1_CONTINUOUS_DRIVE_MODE)) return null;
    int value = _directory.getInt(CanonMakernoteDirectory.TAG_CANON_STATE1_CONTINUOUS_DRIVE_MODE);
    switch (value) {
        case 0:
            if (_directory.getInt(CanonMakernoteDirectory.TAG_CANON_STATE1_SELF_TIMER_DELAY) == 0) {
                return "Single shot";
            } else {
                return "Single shot with self-timer";
            }
        case 1:
            return "Continuous";
        default:
            return "Unknown (" + value + ")";
    }
}
 
开发者ID:ecologylab,项目名称:BigSemanticsJava,代码行数:18,代码来源:CanonMakernoteDescriptor.java


示例17: getFlashDetailsDescription

import com.drew.metadata.MetadataException; //导入依赖的package包/类
public String getFlashDetailsDescription() throws MetadataException
{
    if (!_directory.containsTag(CanonMakernoteDirectory.TAG_CANON_STATE1_FLASH_DETAILS)) return null;
    int value = _directory.getInt(CanonMakernoteDirectory.TAG_CANON_STATE1_FLASH_DETAILS);
    if (((value << 14) & 1) > 0) {
        return "External E-TTL";
    }
    if (((value << 13) & 1) > 0) {
        return "Internal flash";
    }
    if (((value << 11) & 1) > 0) {
        return "FP sync used";
    }
    if (((value << 4) & 1) > 0) {
        return "FP sync enabled";
    }
    return "Unknown (" + value + ")";
}
 
开发者ID:ecologylab,项目名称:BigSemanticsJava,代码行数:19,代码来源:CanonMakernoteDescriptor.java


示例18: getWhiteBalanceDescription

import com.drew.metadata.MetadataException; //导入依赖的package包/类
public String getWhiteBalanceDescription() throws MetadataException
{
    if (!_directory.containsTag(NikonType1MakernoteDirectory.TAG_NIKON_TYPE1_WHITE_BALANCE)) return null;
    int value = _directory.getInt(NikonType1MakernoteDirectory.TAG_NIKON_TYPE1_WHITE_BALANCE);
    switch (value) {
        case 0:
            return "Auto";
        case 1:
            return "Preset";
        case 2:
            return "Daylight";
        case 3:
            return "Incandescense";
        case 4:
            return "Flourescence";
        case 5:
            return "Cloudy";
        case 6:
            return "SpeedLight";
        default:
            return "Unknown (" + value + ")";
    }
}
 
开发者ID:ecologylab,项目名称:BigSemanticsJava,代码行数:24,代码来源:NikonType1MakernoteDescriptor.java


示例19: getQualityDescription

import com.drew.metadata.MetadataException; //导入依赖的package包/类
public String getQualityDescription() throws MetadataException
{
    if (!_directory.containsTag(NikonType1MakernoteDirectory.TAG_NIKON_TYPE1_QUALITY)) return null;
    int value = _directory.getInt(NikonType1MakernoteDirectory.TAG_NIKON_TYPE1_QUALITY);
    switch (value) {
        case 1:
            return "VGA Basic";
        case 2:
            return "VGA Normal";
        case 3:
            return "VGA Fine";
        case 4:
            return "SXGA Basic";
        case 5:
            return "SXGA Normal";
        case 6:
            return "SXGA Fine";
        default:
            return "Unknown (" + value + ")";
    }
}
 
开发者ID:ecologylab,项目名称:BigSemanticsJava,代码行数:22,代码来源:NikonType1MakernoteDescriptor.java


示例20: fromValue

import com.drew.metadata.MetadataException; //导入依赖的package包/类
public static DataFormat fromValue(int value) throws MetadataException
{
    switch (value)
    {
        case 1:  return BYTE;
        case 2:  return STRING;
        case 3:  return USHORT;
        case 4:  return ULONG;
        case 5:  return URATIONAL;
        case 6:  return SBYTE;
        case 7:  return UNDEFINED;
        case 8:  return SSHORT;
        case 9:  return SLONG;
        case 10: return SRATIONAL;
        case 11: return SINGLE;
        case 12: return DOUBLE;
    }

    throw new MetadataException("value '"+value+"' does not represent a known data format.");
}
 
开发者ID:ecologylab,项目名称:BigSemanticsJava,代码行数:21,代码来源:DataFormat.java



注:本文中的com.drew.metadata.MetadataException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DefaultFontMapper类代码示例发布时间:2022-05-21
下一篇:
Java ChannelCondition类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap