# 用powershell取出圖片寬高等資訊 ###### tags: `程式設計` `image` ## 使用方式 1. 打開powershell (可以用shift+右鍵點資料夾空白處找到) 2. 將下面的 C:\images\ 和 C:\images\image.csv 修改為你指定的資料夾路徑 3. 把修改後的字串貼上 ```=powershell [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing") [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") Get-ChildItem -Recurse C:\images\ $originalPath -Include @("*.png", "*.jpg") | % { $image = [System.Drawing.Image]::FromFile($_.FullName) if ($image.width -gt 500 -and $image.height -gt 500) { New-Object PSObject -Property @{ height_pixels = $image.Height width_pixels = $image.Width megapixels = ($image.Height * $image.Width)/1000/1000 megabytes = (($_.Length)/1024)/1024 name = $_.Name fullname = $_.Fullname date = $_.LastWriteTime } } } | Export-Csv 'C:\images\img.csv' -NoTypeInformation ``` 參考來源 https://code.adonline.id.au/script-to-list-image-files-by-size-and-resolution-export-to-excel/
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up