可以用bat直接读取解析文件头,适用于jpg编码:- @echo off
- setlocal enabledelayedexpansion
- for %%i in (*.jpg) do (
- set "dpi="
- call :getDPI "%%i"
- if defined dpi echo,%%i: !dpi!dpi
- )
- del $temp
- pause&exit
-
- :getDPI
- certutil -encodehex -f %1 $temp >nul
- for /f "tokens=2-5,8-12,15-17" %%a in ($temp) do (
- if /i not "%%a%%b%%c%%d"=="ffd8ffe0" (echo,文件编码不符&goto :eof)
- if /i not "%%e%%f%%g%%h%%i"=="4a46494600" (echo,文件编码不符&goto :eof)
- if %%j equ 0 set /a "dpi=96"
- if %%j equ 1 set /a "dpi=0x%%k%%l"
- if %%j equ 2 set /a "dpi=0x%%k%%l*127/50"
- goto :eof
- )
复制代码
|