Skip to content

Instantly share code, notes, and snippets.

@peaeater
Created November 10, 2014 23:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peaeater/f6cd518894bc28d92001 to your computer and use it in GitHub Desktop.
Save peaeater/f6cd518894bc28d92001 to your computer and use it in GitHub Desktop.
Converts PNGs to JPGS with imagemagick.
# 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