Here’s a quick one-liner to re-size photos if you have Imagick installed using PowerShell. It also renames the files with the dimensions specified:
1 2 |
PS C:\Users\SloshDev> gci("*.jpg") | %{convert $_.FullName -resize 500x500 $_.Name -replace '\.jpg$','-500x500.jpg'} |
Ultimately ended up with this to rename the file based on the actual dimensions of the file in the end:
1 2 |
PS C:\Users\SloshDev> gci("*.jpg") | %{convert $_.FullName -resize 500x500 -set filename:area '%wx%h' ($destination + ($_.Name.Trim("\.jpg") + "-%[filename:area].jpg"))} |
This is great if you want to do this within the file itself, however if you need to specify dimensions, source and destination directories, and specific image file extensions you could use a script like this:
1 2 3 4 5 6 7 |
$source = 'C:\User\SloshDev\My Pictures\' $destination = 'C:\User\SloshDev\My Pictures\500's\' $ext = "jpg" $size = "500x500" #Resize Images gci("$source*.$ext") | %{convert $_.FullName -resize $size -set filename:area '%wx%h' ($destination + ($_.Name.Trim("\.$ext") + "-%[filename:area]." + $ext))} |