8
8
[string]$mediatype
9
9
)
10
10
11
- $CurrentScriptVersion = "1.2.27 "
11
+ $CurrentScriptVersion = "1.2.28 "
12
12
$global:HeaderWritten = $false
13
13
$ProgressPreference = 'SilentlyContinue'
14
14
@@ -2603,6 +2603,68 @@ function CheckImageMagick {
2603
2603
}
2604
2604
}
2605
2605
}
2606
+ Else {
2607
+ $CurrentImagemagickversion = & $magick -version
2608
+ $CurrentImagemagickversion = [regex]::Match($CurrentImagemagickversion, 'Version: ImageMagick (\d+(\.\d+){1,2}-\d+)')
2609
+ if ($global:OSType -eq "DockerAlpine"){
2610
+ $Url = "https://pkgs.alpinelinux.org/package/edge/community/x86_64/imagemagick"
2611
+ $response = Invoke-WebRequest -Uri $url
2612
+ $htmlContent = $response.Content
2613
+ $regexPattern = '<th class="header">Version<\/th>\s*<td>\s*<strong>\s*<a[^>]*>([^<]+)<\/a>\s*<\/strong>\s*<\/td>'
2614
+ $Versionmatching = [regex]::Matches($htmlContent, $regexPattern)
2615
+
2616
+ if ($Versionmatching.Count -gt 0) {
2617
+ $LatestImagemagickversion = $Versionmatching[0].Groups[1].Value.split('-')[0]
2618
+ }
2619
+ }
2620
+ Elseif ($global:OSType -eq "Win32NT"){
2621
+ $Url = "https://imagemagick.org/archive/binaries/?C=M;O=D"
2622
+ $result = Invoke-WebRequest -Uri $Url
2623
+ $LatestImagemagickversion = ($result.links.href | Where-Object { $_ -like '*portable-Q16-HDRI-x64.zip' } | Sort-Object -Descending)[0].Replace('-portable-Q16-HDRI-x64.zip','').Replace('ImageMagick-','')
2624
+ }
2625
+ Else {
2626
+ $LatestImagemagickversion = (Invoke-RestMethod -Uri "https://api.github.com/repos/ImageMagick/ImageMagick/releases/latest" -Method Get).tag_name
2627
+ }
2628
+ Write-Entry -Message "Current Imagemagick Version: $($CurrentImagemagickversion.Groups[1].Value)" -Path $configLogging -Color Yellow -log Info
2629
+ Write-Entry -Message "Latest Imagemagick Version: $LatestImagemagickversion" -Path $configLogging -Color DarkMagenta -log Info
2630
+
2631
+ # Auto Update Magick
2632
+ if ($AutoUpdateIM -eq 'True' -and $global:OSType -ne "DockerAlpine" -and $LatestImagemagickversion -gt $CurrentImagemagickversion.Groups[1].Value){
2633
+ if ($global:OSType -eq "Win32NT"){
2634
+ Remove-Item -LiteralPath $magickinstalllocation -Recurse -Force
2635
+ }
2636
+ Else {
2637
+ Remove-Item -LiteralPath "$global:ScriptRoot/magick" -Force
2638
+ }
2639
+ if ($global:OSType -ne "Win32NT") {
2640
+ if ($global:OSType -ne "DockerAlpine") {
2641
+ Write-Entry -Subtext "Downloading the latest Imagemagick portable version for you..." -Path $configLogging -Color Cyan -log Info
2642
+ $magickUrl = "https://imagemagick.org/archive/binaries/magick"
2643
+ Invoke-WebRequest -Uri $magickUrl -OutFile "$global:ScriptRoot/magick"
2644
+ chmod +x "$global:ScriptRoot/magick"
2645
+ Write-Entry -Subtext "Made the portable Magick executable..." -Path $configLogging -Color Green -log Info
2646
+ }
2647
+ }
2648
+ else {
2649
+ Write-Entry -Subtext "Downloading the latest Imagemagick portable version for you..." -Path $configLogging -Color Cyan -log Info
2650
+ $result = Invoke-WebRequest "https://imagemagick.org/archive/binaries/?C=M;O=D"
2651
+ $LatestRelease = ($result.links.href | Where-Object { $_ -like '*portable-Q16-HDRI-x64.zip' } | Sort-Object -Descending)[0]
2652
+ $DownloadPath = Join-Path -Path $global:ScriptRoot -ChildPath (Join-Path -Path 'temp' -ChildPath $LatestRelease)
2653
+ Invoke-WebRequest "https://imagemagick.org/archive/binaries/$LatestRelease" -OutFile $DownloadPath
2654
+ Expand-Archive -Path $DownloadPath -DestinationPath $magickinstalllocation -Force
2655
+ if ((Get-ChildItem -Directory -LiteralPath $magickinstalllocation).name -eq $($LatestRelease.replace('.zip', ''))) {
2656
+ Copy-item -Force -Recurse "$magickinstalllocation\$((Get-ChildItem -Directory -LiteralPath $magickinstalllocation).name)\*" $magickinstalllocation
2657
+ Remove-Item -Recurse -LiteralPath "$magickinstalllocation\$((Get-ChildItem -Directory -LiteralPath $magickinstalllocation).name)" -Force
2658
+ }
2659
+ if (Test-Path -LiteralPath $magickinstalllocation\magick.exe) {
2660
+ Write-Entry -Subtext "Placed Portable ImageMagick here: $magickinstalllocation" -Path $configLogging -Color Green -log Info
2661
+ }
2662
+ Else {
2663
+ Write-Entry -Subtext "Error During extraction, please manually install/copy portable Imagemagick from here: https://imagemagick.org/archive/binaries/$LatestRelease" -Path $configLogging -Color Red -log Error
2664
+ }
2665
+ }
2666
+ }
2667
+ }
2606
2668
}
2607
2669
function CheckOverlayDimensions {
2608
2670
param (
@@ -2853,6 +2915,7 @@ if (!$global:FavProvider) {
2853
2915
$LibstoExclude = $config.PlexPart.LibstoExclude
2854
2916
$PlexUrl = $config.PlexPart.PlexUrl
2855
2917
# Prerequisites Part
2918
+ $AutoUpdateIM = $config.PrerequisitePart.AutoUpdateIM
2856
2919
$show_skipped = $config.PrerequisitePart.show_skipped
2857
2920
$AssetPath = RemoveTrailingSlash $config.PrerequisitePart.AssetPath
2858
2921
@@ -2994,12 +3057,7 @@ Else {
2994
3057
$fileExtensions = @(".otf", ".ttf", ".otc", ".ttc", ".png")
2995
3058
$errorCount = 0
2996
3059
2997
- $CurrentImagemagickversion = & $magick -version
2998
- $CurrentImagemagickversion = [regex]::Match($CurrentImagemagickversion, 'Version: ImageMagick (\d+(\.\d+){1,2}-\d+)')
2999
- $LatestImagemagickversion = (Invoke-RestMethod -Uri "https://api.github.com/repos/ImageMagick/ImageMagick/releases/latest" -Method Get).tag_name
3000
3060
3001
- Write-Entry -Message "Current Imagemagick Version: $($CurrentImagemagickversion.Groups[1].Value)" -Path $global:ScriptRoot\Logs\Scriptlog.log -Color Yellow -log Info
3002
- Write-Entry -Message "Latest Imagemagick Version: $LatestImagemagickversion" -Path $global:ScriptRoot\Logs\Scriptlog.log -Color DarkMagenta -log Info
3003
3061
3004
3062
# Initialize Other Variables
3005
3063
$SeasonsTemp = $null
@@ -3020,6 +3078,9 @@ if ($Testing) {
3020
3078
$configLogging = Join-Path $LogsPath 'Testinglog.log'
3021
3079
}
3022
3080
3081
+ # Check ImageMagick now:
3082
+ CheckImageMagick -magick $magick -magickinstalllocation $magickinstalllocation
3083
+
3023
3084
# Create directories if they don't exist
3024
3085
foreach ($path in $LogsPath, $TempPath, $TestPath, $AssetPath) {
3025
3086
if (!(Test-Path $path)) {
@@ -3104,9 +3165,6 @@ CheckJsonPaths -font $font -backgroundfont $backgroundfont -titlecardfont $title
3104
3165
# Check Plex now:
3105
3166
[xml]$Libs = CheckPlexAccess -PlexUrl $PlexUrl -PlexToken $PlexToken
3106
3167
3107
- # Check ImageMagick now:
3108
- CheckImageMagick -magick $magick -magickinstalllocation $magickinstalllocation
3109
-
3110
3168
# Check overlay artwork for poster, background, and titlecard dimensions
3111
3169
Write-Entry -Message "Checking size of overlay files..." -Path $configLogging -Color White -log Info
3112
3170
CheckOverlayDimensions -Posteroverlay "$Posteroverlay" -Backgroundoverlay "$Backgroundoverlay" -Titlecardoverlay "$titlecardoverlay" -PosterSize "$PosterSize" -BackgroundSize "$BackgroundSize"
0 commit comments