4
I have folder with multiple image files and I want details of only three different formats (jpeg, png and gif). I need to find the images that are exceeding 4 million pixels, so the width multiplied by height can't exceed 4 million pixels. Basically, I just need a list of images that are exceeding the limit and possibly showing the total pixel amount. Is there a way to do it with Powershell? Feel free to recommend some other programs that are able to do this.
I found this question and edited it a bit for my purposes:
Add-Type -Assembly System.Drawing
function Get-Image {
process {
$file = $_
[Drawing.Image]::FromFile($_.FullName) |
ForEach-Object {
$_ | Add-Member -PassThru NoteProperty FullName ('{0}' -f $file.FullName)
}
}
}
Get-ChildItem -Path 'C:\imagefolder' -Filter *.jpg -Recurse | Get-Image | ? { ($_.Width * $_.Height) -gt 4000000 } | select -expa Fullname | get-item
Now, I receive a list of jpg images that exceed the 4-million pixel limit. If I don't use the filter, it goes through all the files in the folder and throws an error for all the non-image files. This is not actually a big problem but would be nice to check only jpg, png and gif files.
Also, I'm still not able to see the total pixel size of the image and not really know how to do that.
What have you tried so far? We aren't a script writing service. – music2myear – 2019-11-28T04:34:58.337
2That's the problem that I'm not familiar with Powershell. Of course, I'm able to google the Powershell commands and similar questions from StackExchange but didn't find anything that would solve my problem. I know it's possible to get the image width and height but I'm not able to put the pieces together. Would be just embarrassing to show what I have tried so far, hehe. – nqw1 – 2019-11-28T05:32:48.540
Please show what you have tried. You're asking us to put forth effort when you are unwilling to show the effort you've given yourself. Your problem is relatively simple: you need to go through a list of files, multiply the width and height pixel values, and flag those over a certain value. So, what have you tried? – music2myear – 2019-11-28T06:54:06.820
I have now added an example what I have tried so far. – nqw1 – 2019-11-28T08:16:53.013