回复 22# wh123wh123
bat没有你所需的处理图像方法,这个也是bat运行POWERSHELL代码,保存为BAT文件,运行请前先备份- <# :
- @echo off
- powershell -noprofile -NoLogo "iex (${%~f0} | out-string)"
- pause
- exit
- #>
- Add-Type -AssemblyName System.Drawing
- function Remove-ICCProfile() {
- param(
- [string[]]$Images,
- [int]$top,
- [int]$bot
- )
- $images.foreach{
- $temp = [IO.Path]::GetTempFileName()
- try {
- $image = [Drawing.Image]::FromFile($_)
- $icc = $image.PropertyItems | Where-Object { $_.Id -eq 0x8773 }
- if($icc){
- #$image.RemovePropertyItem(0x8773)
- $newWidth = $image.Width
- $newHeight = $image.Height - $top - $bot
- $target = New-Object Drawing.Bitmap($newWidth, $newHeight)
- $graphics = [Drawing.Graphics]::FromImage($target)
- $cropRect = [Drawing.Rectangle]::FromLTRB(0, 100, $image.Width, $image.Height - $bot)
- $graphics.DrawImage($image, 0, 0, $cropRect, [Drawing.GraphicsUnit]::Pixel)
- $graphics.Dispose()
- $target.Save($temp, [Drawing.Imaging.ImageFormat]::Jpeg)
- $target.Dispose()
- $image.Dispose()
- [IO.File]::Delete($_)
- [IO.File]::Move($temp, $_)
- }
- }
- catch {
- if ($image -ne $null) { $image.Dispose() }
- if ($target -ne $null) { $target.Dispose() }
- }
- }
- }
-
- $images = [IO.Directory]::EnumerateFiles($pwd.Path, '*.jpg')
- Remove-ICCProfile $images -top 100 -bot 150
复制代码
|