0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

PowerShellで特定のピクセル以下の画像(.jpg)を判定する(備忘録)

Last updated at Posted at 2025-04-23

$path = "画像があるフォルダのpath"

#画像サイズを取得するためのAssembly
Add-Type -AssemblyName System.Drawing

#拡張子が.jpgのファイルのpathを再帰的に取得し$image_path_aryに入れる
$image_path_ary = Get-ChildItem -Path $path -Recurse -Include "*.jpg" | Select-Object -ExpandProperty FullName

#条件に当てはまる画像pathを入れる配列を定義
$err_images =@()

#forする
$image_path_ary | % {

    $tmp_Width = [Drawing.Image]::FromFile($_).Width
    $tmp_Height = [Drawing.Image]::FromFile($_).Height

#縦か横が640ピクセル以下の画像を判定し$err_imagesにいれる
    if($tmp_Width -le 640){
        $err_image += $_
    }elseif($tmp_Height -le 640){
       $err_image += $_ 
    }

}

#結果確認
$err_image.count
$err_image


$err_imageをMove-Itemして小さい画像のみフォルダへ

Move-Item -Path "移動させるファイルのpath" -Destination "移動先のpath"
0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?