LoginSignup
1
1

More than 3 years have passed since last update.

PowerShellでTIFFをJPEGに変換

Posted at

PowerShellでTIFF画像をJPEGに変換する。

TIFFをJPEGに変換するだけの作業が多いので作成。

とりあえずこんな関数を作成。


function Convert2-jpg
    {
    begin { Write-Host "TIFF画像をJPGに変換"
        [Void][System.Reflection.Assembly]::LoadWithPartialName( "System.Drawing" )
         }

    process {
        trap {
            "対象ファイルをパイプラインで入力してください"
            "異常終了!"
            break
            }
        Write-Host "$_"
        $img = [System.Drawing.Image]::FromFile( "$_" )
        $outfile = $_.fullname + ".jpg" 
        Write-Host $outfile
        $img.save( "$outfile" , "jpeg" )
        $img.dispose()
        }

    end { Write-Host "変換完了" }
    }

PowerShellのプロファイルとして保存しておく。

変換するときはPowerShellを立ち上げ、

PS C:\> dir hoge*.tif -Recurse | Convert2-jpg

こんな感じでパイプラインで渡してやると変換される。
ファイル名が .tif.jpg となるのはご愛敬

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1