Created
November 10, 2014 23:57
-
-
Save peaeater/f6cd518894bc28d92001 to your computer and use it in GitHub Desktop.
Converts PNGs to JPGS with imagemagick.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# convert pngs to jpgs | |
# requires imagemagick | |
Param( | |
[int]$size = 1000, | |
[string]$indir = ".", | |
[string]$outdir = $indir | |
) | |
if (!(test-path $outdir)) { | |
mkdir $outdir | |
} | |
$files = ls "$indir\*.*" -include *.png | |
foreach ($file in $files) { | |
$input = ('"{0}"' -f $file.FullName) | |
$output = ('"{0}\{1}.jpg"' -f $outdir, $file.BaseName) | |
$args = "$input -colorspace RGB -resize $size -colorspace sRGB $output" | |
write-host $args | |
start-process convert $args -wait -NoNewWindow | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment