Thanks to visit codestin.com
Credit goes to gitcode.com

metadata-extractor-cj:基于多种媒体格式的元数据提取库项目

metadata-extractor-cj 用于从不同媒体文件中读取元数据,包括 JPEG、TIFF、GIF、BMP等,并提取这些文件中包含的各种元数据信息。

分支7Tags17

metadata-extractor-cj

介绍

metadata-extractor-cj 用于从媒体文件中读取元数据。它可以处理多种文件格式,如 JPEG、TIFF、GIF、BMP等,并提取这些文件中包含的各种元数据信息

特性

  • 🚀 支持JPEG元数据提取功能

  • 🚀 支持PNG元数据提取功能

  • 🚀 支持Mp4元数据提取功能

  • 🚀 支持BMP元数据提取功能

  • 🚀 支持AVI元数据提取功能

  • 🚀 支持MP3元数据提取功能

  • 🚀 支持GIF元数据提取功能

  • 🚀 支持ICO元数据提取功能

  • 🚀 支持PCX元数据提取功能

  • 🚀 支持PSD元数据提取功能

  • 🚀 支持QuickTime元数据提取功能

  • 🚀 支持Heif元数据提取功能

  • 🚀 支持WAV元数据提取功能

  • 🚀 支持TIFF元数据提取功能

软件架构

源码目录

.
├── doc
│   ├── assets
│   └── feature_api.md
├── src
│   ├── imaging
│   ├── lang
│   ├── metadata
│   └── tools
├── test
│    ├── HLT
│    └── LLT
├── CHANGELOG.md
├── LICENSE.txt
├── cjpm.toml
├── README.md
└── README.OpenSource
  • doc 文档目录,用于存放 API 接口文档
  • src 是库源码目录
  • test 存放 HLT 测试用例、LLT 自测用例

接口说明

主要类和函数接口说明详见 API

使用说明

编译构建

两种编译方式

  1. 使用脚本编译
    1. 下载配置编译脚本
    2. ciTest build
  2. 使用包管理器编译
    1. 该三方库依赖 stdx,请参考stdx文档配置CANGJIE_STDX_PATH路径
    2. cjpm build

执行用例

编译用例并执行,步骤如下:

1. 进入 metadata-extractor-cj/test/ 目录下创建 tmp 文件夹,然后编译测试用例

cd metadata-extractor-cj/test/
mkdir tmp
cjc  --import-path xxxxx/metadata-extractor-cj/target/release  -L xxxxx/metadata-extractor-cj/target/release/metadataExtractor4cj -L xxxxx/metadata-extractor-cj/target/release/zlib4cj -L xxxxx/metadata-extractor-cj/target/release/charset4cj -l charset4cj.charset -l metadataExtractor4cj.metadata.jpeg -l metadataExtractor4cj -l metadataExtractor4cj.metadata -l metadataExtractor4cj.metadata.file -l metadataExtractor4cj.metadata.icc -l charset4cj.charset.encoding -l metadataExtractor4cj.tools -l charset4cj.charset.traditionchinese -l charset4cj.charset.simplechinese -l metadataExtractor4cj.metadata.png -l zlib4cj -l charset4cj.charset.singlebyte -l metadataExtractor4cj.imaging -l charset4cj.charset.exception -l charset4cj.charset.korean -l charset4cj.charset.japanese -l charset4cj.charset.unicode -l charset4cj -l metadataExtractor4cj.lang  LLT/test.cj -o tmp/test.cj.out --test

功能示例

JPEG元数据提取功能

import std.fs.*
import metadata_extractor4cj.imaging.*
import metadata_extractor4cj.metadata.*
import metadata_extractor4cj.lang.*
import std.process.*

main () {
    var jpegPath:String = "./crash01.jpg"
    var f = File(jpegPath,Read);
    var medatadata = ImageMetadataReader.readMetadata(f);
    var directories = medatadata.getDirectories()
    for(directory in directories){
        for(tag in directory.getTags()){
            println("${tag.toString()}")
        } 
    }
}

执行结果如下:

[JPEG] Compression Type - Baseline
[JPEG] Data Precision - 8 bits
[JPEG] Image Height - 66 pixels
[JPEG] Image Width - 100 pixels
[JPEG] Number of Components - 3
[JPEG] Component 1 - Y component: Quantization table 0, Sampling factors 2 horiz/2 vert
[JPEG] Component 2 - Cb component: Quantization table 1, Sampling factors 1 horiz/1 vert
[JPEG] Component 3 - Cr component: Quantization table 1, Sampling factors 1 horiz/1 vert
[JpegComment] JPEG Comment - ACD Systems Digital Imaging
[Huffman] Number of Tables - 4 Huffman tables
[File Type] Detected File Type Name - JPEG
[File Type] Detected File Type Long Name - Joint Photographic Experts Group
[File Type] Detected MIME Type - image/jpeg
[File Type] Expected File Name Extension - jpg
[File] File Name - crash01.jpg
[File] File Size - 2338 bytes
[File] File Modified Date - 星期三 三月 19 10:46:17 GMT+8 2025

PNG元数据提取功能

import std.fs.*
import metadata_extractor4cj.imaging.*
import metadata_extractor4cj.metadata.*
import metadata_extractor4cj.lang.*
import std.process.*

main () {
    var dirPath:String = "./mspaint-8x10.png"
    var f = File(dirPath,Read);
    var medatadata = ImageMetadataReader.readMetadata(f);
    var directories = medatadata.getDirectories()
    for(directory in directories){
        for(tag in directory.getTags()){
            println("${tag.toString()}")
        } 
    }
}

执行结果如下:

[PNG-IHDR] Image Width - 8
[PNG-IHDR] Image Height - 12
[PNG-IHDR] Bits Per Sample - 8
[PNG-IHDR] Color Type - True Color
[PNG-IHDR] Compression Type - Deflate
[PNG-IHDR] Filter Method - Adaptive
[PNG-IHDR] Interlace Method - No Interlace
[PNG-sRGB] sRGB Rendering Intent - Perceptual
[PNG-gAMA] Image Gamma - 0.455
[PNG-pHYs] Pixels Per Unit X - 3779
[PNG-pHYs] Pixels Per Unit Y - 3779
[PNG-pHYs] Unit Specifier - Metres
[File Type] Detected File Type Name - PNG
[File Type] Detected File Type Long Name - Portable Network Graphics
[File Type] Detected MIME Type - image/png
[File Type] Expected File Name Extension - png
[File] File Name - mspaint-8x10.png
[File] File Size - 124 bytes
[File] File Modified Date - 星期三 三月 19 10:48:34 GMT+8 2025

Mp4元数据提取功能

import std.fs.*
import std.io.*
import metadata_extractor4cj.imaging.*
import metadata_extractor4cj.metadata.*
import metadata_extractor4cj.metadata.mp4.*
import metadata_extractor4cj.lang.*
import std.collection.*

main () {
    var fpath:String = "./video_merge_test_02.mp4"
    var f = File(fpath,Read);
    var medatadata = Mp4MetadataReader.readMetadata(f);
    var directories = medatadata.getDirectories()
    println(f.info.path)
    for(directory in directories){
        for(tag in directory.getTags()){
            println("${tag.toString()}")
        }
    }
}

执行结果如下:

[MP4] Major Brand - MP4  Base Media v1 [IS0 14496-12:2003]
[MP4] Minor Version - 512
[MP4] Compatible Brands - [MP4  Base Media v1 [IS0 14496-12:2003], MP4  Base Media v2 [ISO 14496-12:2005], MP4 Base w/ AVC ext [ISO 14496-12:2005], MP4 v1 [ISO 14496-1:ch13]]
[MP4] Creation Time - Fri Jan 01 08:00:00 CST 1904
[MP4] Modification Time - Tue Sep 27 09:46:59 CST 2022
[MP4] Duration - 13800
[MP4] Media Time Scale - 1000
[MP4] Duration in Seconds - 00:00:14
[MP4] Transformation Matrix - 65536 0 0 0 65536 0 0 0 1073741824
[MP4] Preferred Rate - 1
[MP4] Preferred Volume - 1
[MP4] Next Track ID - 3
[MP4] Rotation - 0
[MP4 Video] Creation Time - 星期五 一月 01 08:00:00 +08:00 1904
[MP4 Video] Modification Time - 星期五 一月 01 08:00:00 +08:00 1904
[MP4 Video] ISO 639-2 Language Code - und
[MP4 Video] Opcolor - 0 0 0
[MP4 Video] Graphics Mode - Copy
[MP4 Video] Compression Type - H.264
[MP4 Video] Width - 576 pixels
[MP4 Video] Height - 1280 pixels
[MP4 Video] Depth - 24-bit color
[MP4 Video] Horizontal Resolution - 72
[MP4 Video] Vertical Resolution - 72
[MP4 Video] Frame Rate - 30.001
[MP4 Sound] Creation Time - 星期五 一月 01 08:00:00 +08:00 1904
[MP4 Sound] Modification Time - 星期五 一月 01 08:00:00 +08:00 1904
[MP4 Sound] ISO 639-2 Language Code - und
[MP4 Sound] Balance - 0
[MP4 Sound] Format - MPEG-4, Advanced Audio Coding (AAC)
[MP4 Sound] Number of Channels - 2
[MP4 Sound] Sample Size - 16
[MP4 Sound] Sample Rate - 44100
[File Type] Detected File Type Name - MP4
[File Type] Detected File Type Long Name - MPEG-4 Part 14
[File Type] Detected MIME Type - video/mp4
[File Type] Expected File Name Extension - mp4
[File] File Name - video_merge_test_02.mp4
[File] File Size - 1501496 bytes
[File] File Modified Date - 星期四 四月 17 16:46:29 +08:00 2025

BMP元数据提取功能

import std.fs.*
import metadataExtractor4cj.imaging.*
import metadataExtractor4cj.metadata.*
import metadataExtractor4cj.lang.*
import std.process.*

main () {
    var dirPath:String = "./16color-10x10.bmp"
    var f = File(dirPath,Read);
    var medatadata = ImageMetadataReader.readMetadata(f);
    var directories = medatadata.getDirectories()
    for(directory in directories){
        for(tag in directory.getTags()){
            println(tag.toString())
        } 
    }
}

执行结果如下:

[BMP Header] Bitmap type - Standard
[BMP Header] Header Size - 40
[BMP Header] Image Width - 10
[BMP Header] Image Height - 10
[BMP Header] Planes - 1
[BMP Header] Bits Per Pixel - 4
[BMP Header] Compression - None
[BMP Header] X Pixels per Meter - 0
[BMP Header] Y Pixels per Meter - 0
[BMP Header] Palette Colour Count - 0
[BMP Header] Important Colour Count - 0
[File Type] Detected File Type Name - BMP
[File Type] Detected File Type Long Name - Device Independent Bitmap
[File Type] Detected MIME Type - image/bmp
[File Type] Expected File Name Extension - bmp
[File] File Name - 16color-10x10.bmp
[File] File Size - 198 bytes
[File] File Modified Date - 星期一 四月 21 10:47:32 +08:00 2025

AVI元数据提取功能

import std.fs.*
import metadataExtractor4cj.imaging.*
import metadataExtractor4cj.metadata.*
import metadataExtractor4cj.lang.*
import std.process.*

main () {
    var dirPath:String = "./熊出没avi.avi"
    var f = File(dirPath,Read);
    var medatadata = ImageMetadataReader.readMetadata(f);
    var directories = medatadata.getDirectories()
    for(directory in directories){
        for(tag in directory.getTags()){
            println("${tag.toString()}")
        } 
    }
}

执行结果如下:

[AVI] Width - 1280 pixels
[AVI] Height - 720 pixels
[AVI] Stream Count - 2
[AVI] Frames Per Second - 30
[AVI] Duration - 00:00:43
[AVI] Video Codec - FMP4
[AVI] Samples Per Second - 38.281
[File Type] Detected File Type Name - AVI
[File Type] Detected File Type Long Name - Audio Video Interleaved
[File Type] Detected MIME Type - video/vnd.avi
[File Type] Expected File Name Extension - avi
[File] File Name - 熊出没avi.avi
[File] File Size - 5069338 bytes
[File] File Modified Date - 星期一 四月 21 10:49:28 +08:00 2025

MP3元数据提取功能

import std.fs.*
import metadataExtractor4cj.imaging.*
import metadataExtractor4cj.metadata.*
import metadataExtractor4cj.lang.*
import std.process.*

main () {
    var dirPath:String = "./he_32khz.mp3"
    var f = File(dirPath,Read);
    var medatadata = ImageMetadataReader.readMetadata(f);
    var directories = medatadata.getDirectories()
    for(directory in directories){
        for(tag in directory.getTags()){
            println("${tag.toString()}")
        } 
    }
}

执行结果如下:

[MP3] ID - MPEG-1INFO -
[MP3] Layer - Layer III
[MP3] Bitrate - 32
[MP3] Frequency - 32000
[MP3] Mode - Mono
[MP3] Copyright - False
[MP3] Emphasis Method - none
[MP3] Frame Size - 144 bytes
[File Type] Detected File Type Name - MP3
[File Type] Detected File Type Long Name - MPEG Audio Layer III
[File Type] Detected MIME Type - audio/mpeg
[File Type] Expected File Name Extension - mp3
[File] File Name - he_32khz.mp3
[File] File Size - 95760 bytes
[File] File Modified Date - 星期一 四月 21 10:50:59 +08:00 2025

GIF元数据提取功能

import std.fs.*
import metadataExtractor4cj.imaging.*
import metadataExtractor4cj.metadata.*
import metadataExtractor4cj.lang.*
import std.process.*

main () {
    var dirPath:String = "./mspaint-10x10.gif"
    var f = File(dirPath,Read);
    var medatadata = ImageMetadataReader.readMetadata(f);
    var directories = medatadata.getDirectories()
    for(directory in directories){
        for(tag in directory.getTags()){
            println(tag.toString())
        } 
    }
}

执行结果如下:

[GIF Header] GIF Format Version - 89a
[GIF Header] Image Width - 10
[GIF Header] Image Height - 10
[GIF Header] Color Table Size - 256
[GIF Header] Is Color Table Sorted - false
[GIF Header] Bits per Pixel - 8
[GIF Header] Has Global Color Table - true
[GIF Header] Background Color Index - 0
[GIF Control] Disposal Method - Not Specified
[GIF Control] User Input Flag - false
[GIF Control] Transparent Color Flag - true
[GIF Control] Delay - 0
[GIF Control] Transparent Color Index - 252
[GIF Image] Left - 0
[GIF Image] Top - 0
[GIF Image] Width - 10
[GIF Image] Height - 10
[GIF Image] Has Local Colour Table - false
[GIF Image] Is Interlaced - false
[File Type] Detected File Type Name - GIF
[File Type] Detected File Type Long Name - Graphics Interchange Format
[File Type] Detected MIME Type - image/gif
[File Type] Expected File Name Extension - gif
[File] File Name - mspaint-10x10.gif
[File] File Size - 821 bytes
[File] File Modified Date - 星期一 四月 21 10:52:44 +08:00 2025

ICO元数据提取功能

import std.fs.*
import std.io.*
import metadata_extractor4cj.imaging.*
import metadata_extractor4cj.metadata.ico.*

main () {
    var fpath:String = "./1.ico"
    var f = File(fpath,Read);
    var medatadata = IcoMetadataReader.readMetadata(f);
    var directories = medatadata.getDirectories()
    for(directory in directories){
        for(tag in directory.getTags()){
            println("${tag.toString()}")
        }
    }
}

执行结果如下:

[ICO] Image Type - Icon
[ICO] Image Width - 48 pixels
[ICO] Image Height - 48 pixels
[ICO] Colour Palette Size - 16 colours
[ICO] Colour Planes - 1
[ICO] Bits Per Pixel - 4
[ICO] Image Size Bytes - 1640
[ICO] Image Offset Bytes - 166
[ICO] Image Type - Icon
[ICO] Image Width - 32 pixels
[ICO] Image Height - 32 pixels
[ICO] Colour Palette Size - 16 colours
[ICO] Colour Planes - 1
[ICO] Bits Per Pixel - 4
[ICO] Image Size Bytes - 744
[ICO] Image Offset Bytes - 1806
[ICO] Image Type - Icon
[ICO] Image Width - 16 pixels
[ICO] Image Height - 16 pixels
[ICO] Colour Palette Size - 16 colours
[ICO] Colour Planes - 1
[ICO] Bits Per Pixel - 4
[ICO] Image Size Bytes - 296
[ICO] Image Offset Bytes - 2550
[ICO] Image Type - Icon
[ICO] Image Width - 48 pixels
[ICO] Image Height - 48 pixels
[ICO] Colour Palette Size - No palette
[ICO] Colour Planes - 1
[ICO] Bits Per Pixel - 8
[ICO] Image Size Bytes - 3752
[ICO] Image Offset Bytes - 2846
[ICO] Image Type - Icon
[ICO] Image Width - 32 pixels
[ICO] Image Height - 32 pixels
[ICO] Colour Palette Size - No palette
[ICO] Colour Planes - 1
[ICO] Bits Per Pixel - 8
[ICO] Image Size Bytes - 2216
[ICO] Image Offset Bytes - 6598
[ICO] Image Type - Icon
[ICO] Image Width - 16 pixels
[ICO] Image Height - 16 pixels
[ICO] Colour Palette Size - No palette
[ICO] Colour Planes - 1
[ICO] Bits Per Pixel - 8
[ICO] Image Size Bytes - 1384
[ICO] Image Offset Bytes - 8814
[ICO] Image Type - Icon
[ICO] Image Width - 128 pixels
[ICO] Image Height - 128 pixels
[ICO] Colour Palette Size - No palette
[ICO] Colour Planes - 1
[ICO] Bits Per Pixel - 32
[ICO] Image Size Bytes - 67624
[ICO] Image Offset Bytes - 10198
[ICO] Image Type - Icon
[ICO] Image Width - 48 pixels
[ICO] Image Height - 48 pixels
[ICO] Colour Palette Size - No palette
[ICO] Colour Planes - 1
[ICO] Bits Per Pixel - 32
[ICO] Image Size Bytes - 9640
[ICO] Image Offset Bytes - 77822
[ICO] Image Type - Icon
[ICO] Image Width - 32 pixels
[ICO] Image Height - 32 pixels
[ICO] Colour Palette Size - No palette
[ICO] Colour Planes - 1
[ICO] Bits Per Pixel - 32
[ICO] Image Size Bytes - 4264
[ICO] Image Offset Bytes - 87462
[ICO] Image Type - Icon
[ICO] Image Width - 16 pixels
[ICO] Image Height - 16 pixels
[ICO] Colour Palette Size - No palette
[ICO] Colour Planes - 1
[ICO] Bits Per Pixel - 32
[ICO] Image Size Bytes - 1128
[ICO] Image Offset Bytes - 91726
[File Type] Detected File Type Name - ICO
[File Type] Detected File Type Long Name - Windows Icon
[File Type] Detected MIME Type - image/x-icon
[File Type] Expected File Name Extension - ico
[File] File Name - 1.ico
[File] File Size - 92854 bytes
[File] File Modified Date - 星期五 六月 13 10:38:50 +08:00 2025

PCX元数据提取功能

import std.fs.*
import std.io.*
import metadata_extractor4cj.imaging.*
import metadata_extractor4cj.metadata.pcx.*

main () {
    var fpath:String = "./photoshop-8x12-rgb24.pcx"
    var f = File(fpath,Read);
    var medatadata = PcxMetadataReader.readMetadata(f);
    var directories = medatadata.getDirectories()
    for(directory in directories){
        for(tag in directory.getTags()){
            println("${tag.toString()}")
        }
    }
}

执行结果如下:

[PNG-IHDR] Image Width - 8
[PNG-IHDR] Image Height - 12
[PNG-IHDR] Bits Per Sample - 8
[PNG-IHDR] Color Type - True Color
[PNG-IHDR] Compression Type - Deflate
[PNG-IHDR] Filter Method - Adaptive
[PNG-IHDR] Interlace Method - No Interlace
[PNG-tEXt] Textual Data - Software: Adobe ImageReady
[File Type] Detected File Type Name - PNG
[File Type] Detected File Type Long Name - Portable Network Graphics
[File Type] Detected MIME Type - image/png
[File Type] Expected File Name Extension - png
[File] File Name - photoshop-8x12-rgb24.pcx
[File] File Size - 1020 bytes
[File] File Modified Date - 星期五 六月 13 11:01:27 +08:00 2025

PSD元数据提取功能

import std.fs.*
import std.fs.Directory as stdFsDirectory
import std.io.*
import metadata_extractor4cj.imaging.*

main () {
    var fpath:String = "./withIptcPhotoshop6.jpg"
    var f = File(fpath,Read);
    var medatadata = Mp4MetadataReader.readMetadata(f);
    var directories = medatadata.getDirectories()
    println(f.info.path)
    for(directory in directories){
        for(tag in directory.getTags()){
            println("${tag.toString()}")
        }
    }
}

执行结果如下:

[06-13 17:05:50] INFO - [JPEG] Compression Type - Baseline
[06-13 17:05:50] INFO - [JPEG] Data Precision - 8 bits
[06-13 17:05:50] INFO - [JPEG] Image Height - 100 pixels
[06-13 17:05:50] INFO - [JPEG] Image Width - 110 pixels
[06-13 17:05:50] INFO - [JPEG] Number of Components - 3
[06-13 17:05:50] INFO - [JPEG] Component 1 - Y component: Quantization table 0, Sampling factors 1 horiz/1 vert
[JPEG] Component 2 - Cb component: Quantization table 1, Sampling factors 1 horiz/1 vert
[JPEG] Component 3 - Cr component: Quantization table 1, Sampling factors 1 horiz/1 vert
[Huffman] Number of Tables - 4 Huffman tables
[Photoshop] Resolution Info - 108x108 DPI
[Photoshop] Global Angle - 120
[Photoshop] Global Altitude - 30
[Photoshop] Print Flags - 0 0 0 0 0 0 0 0 1
[Photoshop] Copyright Flag - No
[Photoshop] Print Flags Information - 0 1 0 0 0 0 0 0 0 2
[Photoshop] Color Halftoning Information - [72 values]
[Photoshop] Color Transfer Functions - [112 values]
[Photoshop] Grid and Guides Information - 0 0 0 1 0 0 2 64 0 0 2 64 0 0 0 0
[Photoshop] URL List - 0
[Photoshop] Slices - wizard (0,0,100,110) 1 Slices
[Photoshop] ICC Untagged Profile - 1
[Photoshop] Seed Number - 1
[Photoshop] Thumbnail Data - JpegRGB, 110x100, Decomp 33200 bytes, 1572865 bpp, 4364 bytes
[Photoshop] Version Info - 1 (Adobe Photoshop, Adobe Photoshop 6.0) 1
[Photoshop] Plug-in 1 Data - [1154 values]
[Photoshop] Plug-in 2 Data - [1188 values]
[Photoshop] JPEG Quality - 7 (Medium), Standard format,  3 scans
[IPTC] Application Record Version - 2
[IPTC] Caption/Abstract - Caption PS6
[IPTC] Caption Writer/Editor - CaptionWriter
[IPTC] Headline - Headline
[IPTC] Special Instructions - Special Instr.
[IPTC] By-line - Byline
[IPTC] By-line Title - BylineTitle
[IPTC] Credit - Credits
[IPTC] Source - Source
[IPTC] Object Name - ObjectName
[IPTC] City - City
[IPTC] Province/State - State
[IPTC] Country/Primary Location Name - Country
[IPTC] Original Transmission Reference - Transmission
[IPTC] Category - Cat
[IPTC] Supplemental Category(s) - Supl. Category1 Supl. Category2
[IPTC] Copyright Notice - Copyright
[File Type] Detected File Type Name - JPEG
[File Type] Detected File Type Long Name - Joint Photographic Experts Group
[File Type] Detected MIME Type - image/jpeg
[File Type] Expected File Name Extension - jpg
[File] File Name - withIptcPhotoshop6.jpg
[File] File Size - 13260 bytes
[File] File Modified Date - 星期五 六月 13 17:05:48 +08:00 2025

QuickTime元数据提取功能

import std.fs.*
import metadata_extractor4cj.imaging.*
import metadata_extractor4cj.metadata.*
import metadata_extractor4cj.lang.*
import std.process.*

main () {
    var jpegPath:String = "./1666957294.mov"
    var f = File(jpegPath,Read);
    var medatadata = QuickTimeMetadataReader.readMetadata(f);
    var directories = medatadata.getDirectories()
    println(f.info.path)
    for(directory in directories){
        for(tag in directory.getTags()){
            println("${tag.toString()}")
        } 
    }
}

执行结果如下:

[QuickTime] Major Brand - Apple QuickTime (.MOV/QT)
[QuickTime] Minor Version - 0
[QuickTime] Compatible Brands - [Apple QuickTime (.MOV/QT)]
[QuickTime] Creation Time - 星期五 十月 28 19:13:40 +08:00 2022
[QuickTime] Modification Time - 星期五 十月 28 19:13:42 +08:00 2022
[QuickTime] Duration - 42860
[QuickTime] Media Time Scale - 15360
[QuickTime] Duration in Seconds - 0:0:3
[QuickTime] Preferred Rate - 1
[QuickTime] Preferred Volume - 1
[QuickTime] Preview Time - 0
[QuickTime] Preview Duration - 0
[QuickTime] Poster Time - 0
[QuickTime] Selection Time - 0
[QuickTime] Selection Duration - 0
[QuickTime] Current Time - 0
[QuickTime] Next Track ID - 3
[QuickTime Sound] Creation Time - 星期五 十月 28 19:13:40 +08:00 2022
[QuickTime Sound] Modification Time - 星期五 十月 28 19:13:42 +08:00 2022
[QuickTime Sound] Balance - 0
[QuickTime Sound] Format - MPEG-4, Advanced Audio Coding (AAC)
[QuickTime Sound] Number of Channels - 2
[QuickTime Sound] Sample Size - 16
[QuickTime Sound] Sample Rate - 48000
[QuickTime Video] Creation Time - 星期五 十月 28 19:13:40 +08:00 2022
[QuickTime Video] Modification Time - 星期五 十月 28 19:13:42 +08:00 2022
[QuickTime Video] Opcolor - 32768 32768 32768
[QuickTime Video] Graphics Mode - Dither copy
[QuickTime Video] Vendor - Unknown
[QuickTime Video] Compression Type - H.264
[QuickTime Video] Temporal Quality - 512
[QuickTime Video] Spatial Quality - 512
[QuickTime Video] Width - 1920 pixels
[QuickTime Video] Height - 1080 pixels
[QuickTime Video] Compressor Name - H.264
[QuickTime Video] Depth - 24-bit color
[QuickTime Video] Color Table - None
[QuickTime Video] Horizontal Resolution - 72
[QuickTime Video] Vertical Resolution - 72
[QuickTime Video] Frame Rate - 128
[QuickTime Metadata] Encoder - Lavf58.76.100

Heif元数据提取功能

import std.fs.*
import std.io.*
import metadata_extractor4cj.imaging.*

main () {
        var jpegPath:String = "./simple.heif"
        var f = File(jpegPath,Read);
        let dataArray:Array<Byte> = readToEnd(f)
        let inputStream:ByteBuffer = ByteBuffer(dataArray)
        var medatadata = HeifMetadataReader.readMetadata(inputStream);
        var directories = medatadata.getDirectories()
        println(f.info.path)
        for(directory in directories){
            for(tag in directory.getTags()){
                println("${tag.toString()}")
            } 
        }
}

执行结果如下:

[HEIF] Major Brand - heic
[HEIF] Minor Version - 0
[HEIF] Compatible Brands - mif1 heic
[HEIF] Width - 800 pixels
[HEIF] Height - 600 pixels

WAV元数据提取功能

import std.fs.*
import std.io.*
import metadata_extractor4cj.imaging.*

main () {
        var jpegPath:String = "./ALARM.WAV"
        var f = File(jpegPath,Read);
        var medatadata = ImageMetadataReader.readMetadata(f);
        var directories = medatadata.getDirectories()
        println(f.info.path)
        for(directory in directories){
            for(tag in directory.getTags()){
                println("${tag.toString()}")
            } 
        }
}

执行结果如下:

[WAV] Bits Per Sample - 16
[WAV] Format - Microsoft PCM
[WAV] Channels - 1
[WAV] Samples Per Second - 22050
[WAV] Bytes Per Second - 44100
[WAV] Block Alignment - 2
[WAV] Duration - 00:00:01
[File Type] Detected File Type Name - Wav
[File Type] Detected File Type Long Name - Waveform Audio File Format
[File Type] Detected MIME Type - audio/vnd.wave
[File Type] Expected File Name Extension - wav
[File] File Name - ALARM.WAV
[File] File Size - 34016 bytes
[File] File Modified Date - 星期三 七月 23 15:38:20 +08:00 2025

TIFF元数据提取功能

import std.fs.*
import std.io.*
import metadata_extractor4cj.imaging.*

main () {
        var jpegPath:String = "./rgb.tiff"
        var f = File(jpegPath,Read);
        var medatadata = ImageMetadataReader.readMetadata(f);
        var directories = medatadata.getDirectories()
        println(f.info.path)
        for(directory in directories){
            for(tag in directory.getTags()){
                println("${tag.toString()}")
            } 
        }
}

执行结果如下:

[Exif IFD0] Image Width - 800 pixels
[Exif IFD0] Image Height - 519 pixels
[Exif IFD0] Bits Per Sample - 8 8 8 bits/component/pixel
[Exif IFD0] Compression - LZW
[Exif IFD0] Photometric Interpretation - RGB
[Exif IFD0] Strip Offsets - 8
[Exif IFD0] Orientation - Top, left side (Horizontal / normal)
[Exif IFD0] Samples Per Pixel - 3 samples/pixel
[Exif IFD0] Rows Per Strip - 519 rows/strip
[Exif IFD0] Strip Byte Counts - 1451874 bytes
[Exif IFD0] X Resolution - 1200 dots per inch
[Exif IFD0] Y Resolution - 1200 dots per inch
[Exif IFD0] Planar Configuration - Chunky (contiguous for each subsampling pixel)
[Exif IFD0] Resolution Unit - Inch
[File Type] Detected File Type Name - Tiff
[File Type] Detected File Type Long Name - Tagged Image File Format
[File Type] Detected MIME Type - image/tiff
[File Type] Expected File Name Extension - tiff
[File] File Name - rgb.tiff
[File] File Size - 1452078 bytes
[File] File Modified Date - 星期三 七月 23 16:17:52 +08:00 2025

开源协议

本项目基于 Apache License 2.0 ,请自由地享受和参与开源。

参与贡献

欢迎给我们提交PR,欢迎给我们提交Issue,欢迎参与任何形式的贡献。

项目介绍

metadata-extractor-cj 用于从不同媒体文件中读取元数据,包括 JPEG、TIFF、GIF、BMP等,并提取这些文件中包含的各种元数据信息。

定制我的领域