本文概述
- Tika ImageParser构造函数
- Tika ImageParser方法
- Tika图像解析器示例
Tika ImageParser构造函数
Constructor | Description |
---|---|
公共ImageParser() | 它用于创建类的实例。 |
Method | Description |
---|---|
公共Set < MediaType> getSupportedTypes(ParseContext上下文) | 当与给定的解析上下文一起使用时, 返回此解析器支持的媒体类型集。 |
公共无效解析(InputStream流, ContentHandler处理程序, 元数据元数据, ParseContext上下文)引发IOException, SAXException, TikaException | 将文档流解析为一系列XHTML SAX事件。在给定的元数据对象中填写相关的文档元数据。 |
package tikaexample;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import org.apache.tika.exception.TikaException;
import org.apache.tika.metadata.Metadata;
import org.apache.tika.parser.ParseContext;
import org.apache.tika.parser.jpeg.JpegParser;
import org.apache.tika.sax.BodyContentHandler;
import org.xml.sax.SAXException;
public class ImageExample {public static void main(final String[] args) throws IOException, SAXException, TikaException {BodyContentHandler handler = new BodyContentHandler();
Metadata metadata = http://www.srcmini.com/new Metadata();
FileInputStream inputstream = new FileInputStream(new File("srcmini.jpg"));
ParseContext pcontext = new ParseContext();
JpegParserJpegParser = new JpegParser();
JpegParser.parse(inputstream, handler, metadata, pcontext);
System.out.println("Document Content :" + handler.toString());
System.out.println("Document Metadata :");
String[] metadataNames = metadata.names();
for(String name : metadataNames) {System.out.println(name + ": " + metadata.get(name));
}}}
【Tika图像提取示例】输出
Document Content :Document Metadata :Exif Versi2on: 2.30Brightness: 0Compression Type: BaselineImage Description: Number of Components: 3Component 2: Cb component: Quantization table 1, Sampling factors 1 horiz/1 vertFocal Length: 4.1 mmComponent 1: Y component: Quantization table 0, Sampling factors 2 horiz/1 vertUnknown tag (0x9410): [3656 values]tiff:ResolutionUnit: InchDate/Time Original: 2015:06:11 20:53:00tiff:Make: SONYUnknown tag (0x201f): 0 0 0 0Unknown tag (0x200d): 1Flash Level: NormalComponent 3: Cr component: Quantization table 1, Sampling factors 1 horiz/1 vertFlash Exposure Compensation: 0 EVUnknown tag (0xb046): 0F-Number: f/3.5Unknown tag (0x2015): 65535Focus Mode: ManualSensitivity Type: Recommended Exposure Indextiff:BitsPerSample: 8Unknown tag (0x0002): 0x00000001Unknown tag (0x2027): 4896 3672 4375 1897
推荐阅读
- Tika简要简介
- Tika HTML文件提取示例
- Tika Flv文件提取示例
- 8款Android的最佳免费指纹锁应用软件下载推荐合集
- 支付宝支付扫码付和app支付,回调验证签名失败问题
- call和apply方法的异同
- 第35篇进程之间的通信 Queue Pipe 进程池Pool,p.apply()方法,p.apply_async()方法
- Django中的app及mysql数据库篇(ORM操作)
- our happy ending(状压dp)