-
Notifications
You must be signed in to change notification settings - Fork 0
/
generateDeriv.ps1
34 lines (29 loc) · 1.81 KB
/
generateDeriv.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# UC Libraries, DigitzeUC Spokes
# Generate derivatives for DRC
# 2015-12-10, Nathan Tallman
Get-ChildItem "." -recurse -filter *.tif | `
Foreach {
$image = New-Object -ComObject Wia.ImageFile
$image.LoadFile($_.FullName)
If ($image.Width -gt 5000 -lt 15000 -Or $image.Height -gt 5000 -lt 15000)
{
.\ImageMagick\convert.exe -resample 300 -resize "5000x5000>" $_.FullName ($_.DirectoryName + "\" + $_.BaseName + ".jpg")
.\ImageMagick\convert.exe $_.FullName ($_.DirectoryName + "\" + $_.BaseName + ".jp2")
.\ImageMagick\convert.exe -thumbnail 100x100 $_.FullName ($_.DirectoryName + "\" + $_.BaseName + ".jpg.jpg")
Copy-Item -Path ($_.DirectoryName + "\" + $_.BaseName + ".jpg.jpg") -Destination ($_.DirectoryName + "\" + $_.BaseName + ".jp2.jpg")
}
ElseIf ($image.Width -ge 15000 -Or $image.Height -ge 15000)
{
.\ImageMagick\convert.exe -resample 300 -resize "5000x5000>" $_.FullName ($_.DirectoryName + "\" + $_.BaseName + ".jpg")
.\ImageMagick\convert.exe -resize "15000x15000>" $_.FullName ($_.DirectoryName + "\" + $_.BaseName + ".jp2")
.\ImageMagick\convert.exe -thumbnail 100x100 $_.FullName ($_.DirectoryName + "\" + $_.BaseName + ".jpg.jpg")
Copy-Item -Path ($_.DirectoryName + "\" + $_.BaseName + ".jpg.jpg") -Destination ($_.DirectoryName + "\" + $_.BaseName + ".jp2.jpg")
}
Else
{
.\ImageMagick\convert.exe -resample 300 $_.FullName ($_.DirectoryName + "\" + $_.BaseName + ".jpg")
.\ImageMagick\convert.exe $_.FullName ($_.DirectoryName + "\" + $_.BaseName + ".jp2")
.\ImageMagick\convert.exe -thumbnail 100x100 $_.FullName ($_.DirectoryName + "\" + $_.BaseName + ".jpg.jpg")
Copy-Item -Path ($_.DirectoryName + "\" + $_.BaseName + ".jpg.jpg") -Destination ($_.DirectoryName + "\" + $_.BaseName + ".jp2.jpg")
}
}