Skip to content

Instantly share code, notes, and snippets.

@peaeater
Created March 19, 2014 16:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peaeater/9646158 to your computer and use it in GitHub Desktop.
Save peaeater/9646158 to your computer and use it in GitHub Desktop.
Produces a JPG per JP2, given an input directory. Output size defaults to 1000px width, and output name mirrors source JP2s. Requires imagemagick.
# convert .jp2 to .jpg
# requires imagemagick
Param(
[int]$size = 1000,
[string]$indir = ".",
[string]$outdir = ".\jpg"
)
if (!(test-path $outdir)) {
mkdir $outdir
}
$files = ls "$indir\*.*" -include *.jp2
foreach ($file in $files) {
$input = ('"{0}"' -f $file.FullName)
$output = ('"{0}\{1}.jpg"' -f $outdir, $file.BaseName)
$args = "$input -resize $size $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