Skip to content

Commit

Permalink
fix truncate handeling with quotes in title
Browse files Browse the repository at this point in the history
  • Loading branch information
fscorrupt committed Apr 3, 2024
1 parent bf2ddda commit 5822cc8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
32 changes: 21 additions & 11 deletions PlexPosterMaker.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ param (
[switch]$Testing
)

$CurrentScriptVersion = "1.0.67"
$CurrentScriptVersion = "1.0.68"
$global:HeaderWritten = $false
$ProgressPreference = 'SilentlyContinue'

Expand Down Expand Up @@ -2720,7 +2720,8 @@ if ($Manual) {

if ($AddText -eq 'true') {
$joinedTitle = $joinedTitle -replace '"', '""'
$optimalFontSize = Get-OptimalPointSize -text $joinedTitle -font $fontImagemagick -box_width $MaxWidth -box_height $MaxHeight -min_pointsize $minPointSize -max_pointsize $maxPointSize
$joinedTitlePointSize = $joinedTitle -replace '""', '""""'
$optimalFontSize = Get-OptimalPointSize -text $joinedTitlePointSize -font $fontImagemagick -box_width $MaxWidth -box_height $MaxHeight -min_pointsize $minPointSize -max_pointsize $maxPointSize
Write-Entry -Subtext "Optimal font size set to: '$optimalFontSize'" -Path $global:ScriptRoot\Logs\Manuallog.log -Color White -log Info
$Arguments = "`"$PosterImage`" -gravity center -background None -layers Flatten `( -font `"$fontImagemagick`" -pointsize `"$optimalFontSize`" -fill `"$fontcolor`" -size `"$boxsize`" -background none caption:`"$joinedTitle`" -trim -gravity south -extent `"$boxsize`" `) -gravity south -geometry +0`"$text_offset`" -quality $global:outputQuality -composite `"$PosterImage`""
Write-Entry -Subtext " Applying Poster text: `"$joinedTitle`"" -Path $global:ScriptRoot\Logs\Manuallog.log -Color White -log Info
Expand Down Expand Up @@ -4288,7 +4289,8 @@ else {

if ($AddText -eq 'true') {
$joinedTitle = $joinedTitle -replace '"', '""'
$optimalFontSize = Get-OptimalPointSize -text $joinedTitle -font $fontImagemagick -box_width $MaxWidth -box_height $MaxHeight -min_pointsize $minPointSize -max_pointsize $maxPointSize
$joinedTitlePointSize = $joinedTitle -replace '""', '""""'
$optimalFontSize = Get-OptimalPointSize -text $joinedTitlePointSize -font $fontImagemagick -box_width $MaxWidth -box_height $MaxHeight -min_pointsize $minPointSize -max_pointsize $maxPointSize
if (!$global:IsTruncated) {
Write-Entry -Subtext "Optimal font size set to: '$optimalFontSize'" -Path $global:ScriptRoot\Logs\Scriptlog.log -Color White -log Info
$Arguments = "`"$PosterImage`" -gravity center -background None -layers Flatten `( -font `"$fontImagemagick`" -pointsize `"$optimalFontSize`" -fill `"$fontcolor`" -size `"$boxsize`" -background none caption:`"$joinedTitle`" -trim -gravity south -extent `"$boxsize`" `) -gravity south -geometry +0`"$text_offset`" -quality $global:outputQuality -composite `"$PosterImage`""
Expand Down Expand Up @@ -4554,7 +4556,8 @@ else {

if ($AddBackgroundText -eq 'true') {
$joinedTitle = $joinedTitle -replace '"', '""'
$optimalFontSize = Get-OptimalPointSize -text $joinedTitle -font $fontImagemagick -box_width $BackgroundMaxWidth -box_height $BackgroundMaxHeight -min_pointsize $BackgroundminPointSize -max_pointsize $BackgroundmaxPointSize
$joinedTitlePointSize = $joinedTitle -replace '""', '""""'
$optimalFontSize = Get-OptimalPointSize -text $joinedTitlePointSize -font $fontImagemagick -box_width $BackgroundMaxWidth -box_height $BackgroundMaxHeight -min_pointsize $BackgroundminPointSize -max_pointsize $BackgroundmaxPointSize
if (!$global:IsTruncated) {
Write-Entry -Subtext "Optimal font size set to: '$optimalFontSize'" -Path $global:ScriptRoot\Logs\Scriptlog.log -Color White -log Info
$Arguments = "`"$backgroundImage`" -gravity center -background None -layers Flatten `( -font `"$fontImagemagick`" -pointsize `"$optimalFontSize`" -fill `"$Backgroundfontcolor`" -size `"$Backgroundboxsize`" -background none caption:`"$joinedTitle`" -trim -gravity south -extent `"$Backgroundboxsize`" `) -gravity south -geometry +0`"$Backgroundtext_offset`" -quality $global:outputQuality -composite `"$backgroundImage`""
Expand Down Expand Up @@ -4909,7 +4912,8 @@ else {

if ($AddText -eq 'true') {
$joinedTitle = $joinedTitle -replace '"', '""'
$optimalFontSize = Get-OptimalPointSize -text $joinedTitle -font $fontImagemagick -box_width $MaxWidth -box_height $MaxHeight -min_pointsize $minPointSize -max_pointsize $maxPointSize
$joinedTitlePointSize = $joinedTitle -replace '""', '""""'
$optimalFontSize = Get-OptimalPointSize -text $joinedTitlePointSize -font $fontImagemagick -box_width $MaxWidth -box_height $MaxHeight -min_pointsize $minPointSize -max_pointsize $maxPointSize
if (!$global:IsTruncated) {
Write-Entry -Subtext "Optimal font size set to: '$optimalFontSize'" -Path $global:ScriptRoot\Logs\Scriptlog.log -Color White -log Info
$Arguments = "`"$PosterImage`" -gravity center -background None -layers Flatten `( -font `"$fontImagemagick`" -pointsize `"$optimalFontSize`" -fill `"$fontcolor`" -size `"$boxsize`" -background none caption:`"$joinedTitle`" -trim -gravity south -extent `"$boxsize`" `) -gravity south -geometry +0`"$text_offset`" -quality $global:outputQuality -composite `"$PosterImage`""
Expand Down Expand Up @@ -5185,7 +5189,8 @@ else {

if ($AddBackgroundText -eq 'true') {
$joinedTitle = $joinedTitle -replace '"', '""'
$optimalFontSize = Get-OptimalPointSize -text $joinedTitle -font $fontImagemagick -box_width $BackgroundMaxWidth -box_height $BackgroundMaxHeight -min_pointsize $BackgroundminPointSize -max_pointsize $BackgroundmaxPointSize
$joinedTitlePointSize = $joinedTitle -replace '""', '""""'
$optimalFontSize = Get-OptimalPointSize -text $joinedTitlePointSize -font $fontImagemagick -box_width $BackgroundMaxWidth -box_height $BackgroundMaxHeight -min_pointsize $BackgroundminPointSize -max_pointsize $BackgroundmaxPointSize
if (!$global:IsTruncated) {
Write-Entry -Subtext "Optimal font size set to: '$optimalFontSize'" -Path $global:ScriptRoot\Logs\Scriptlog.log -Color White -log Info
$Arguments = "`"$backgroundImage`" -gravity center -background None -layers Flatten `( -font `"$fontImagemagick`" -pointsize `"$optimalFontSize`" -fill `"$Backgroundfontcolor`" -size `"$Backgroundboxsize`" -background none caption:`"$joinedTitle`" -trim -gravity south -extent `"$Backgroundboxsize`" `) -gravity south -geometry +0`"$Backgroundtext_offset`" -quality $global:outputQuality -composite `"$backgroundImage`""
Expand Down Expand Up @@ -5487,7 +5492,8 @@ else {

if ($AddSeasonText -eq 'true') {
$global:seasonTitle = $global:seasonTitle -replace '"', '""'
$optimalFontSize = Get-OptimalPointSize -text $global:seasonTitle -font $fontImagemagick -box_width $SeasonMaxWidth -box_height $SeasonMaxHeight -min_pointsize $SeasonminPointSize -max_pointsize $SeasonmaxPointSize
$joinedTitlePointSize = $global:seasonTitle -replace '""', '""""'
$optimalFontSize = Get-OptimalPointSize -text $joinedTitlePointSize -font $fontImagemagick -box_width $SeasonMaxWidth -box_height $SeasonMaxHeight -min_pointsize $SeasonminPointSize -max_pointsize $SeasonmaxPointSize
if (!$global:IsTruncated) {
Write-Entry -Subtext "Optimal font size set to: '$optimalFontSize'" -Path $global:ScriptRoot\Logs\Scriptlog.log -Color White -log Info

Expand Down Expand Up @@ -5888,7 +5894,8 @@ else {
$global:EPTitle = $global:EPTitle.ToUpper()
}
$global:EPTitle = $global:EPTitle -replace '"', '""'
$optimalFontSize = Get-OptimalPointSize -text $global:EPTitle -font $TitleCardfontImagemagick -box_width $TitleCardEPTitleMaxWidth -box_height $TitleCardEPTitleMaxHeight -min_pointsize $TitleCardEPTitleminPointSize -max_pointsize $TitleCardEPTitlemaxPointSize
$joinedTitlePointSize = $global:EPTitle -replace '""', '""""'
$optimalFontSize = Get-OptimalPointSize -text $joinedTitlePointSize -font $TitleCardfontImagemagick -box_width $TitleCardEPTitleMaxWidth -box_height $TitleCardEPTitleMaxHeight -min_pointsize $TitleCardEPTitleminPointSize -max_pointsize $TitleCardEPTitlemaxPointSize
if (!$global:IsTruncated) {
Write-Entry -Subtext "Optimal font size set to: '$optimalFontSize'" -Path $global:ScriptRoot\Logs\Scriptlog.log -Color White -log Info

Expand All @@ -5905,7 +5912,8 @@ else {
$global:SeasonEPNumber = $global:SeasonEPNumber.ToUpper()
}
$global:SeasonEPNumber = $global:SeasonEPNumber -replace '"', '""'
$optimalFontSize = Get-OptimalPointSize -text $global:SeasonEPNumber -font $TitleCardfontImagemagick -box_width $TitleCardEPMaxWidth -box_height $TitleCardEPMaxHeight -min_pointsize $TitleCardEPminPointSize -max_pointsize $TitleCardEPmaxPointSize
$joinedTitlePointSize = $global:SeasonEPNumber -replace '""', '""""'
$optimalFontSize = Get-OptimalPointSize -text $joinedTitlePointSize -font $TitleCardfontImagemagick -box_width $TitleCardEPMaxWidth -box_height $TitleCardEPMaxHeight -min_pointsize $TitleCardEPminPointSize -max_pointsize $TitleCardEPmaxPointSize
if (!$global:IsTruncated) {
Write-Entry -Subtext "Optimal font size set to: '$optimalFontSize'" -Path $global:ScriptRoot\Logs\Scriptlog.log -Color White -log Info

Expand Down Expand Up @@ -6291,7 +6299,8 @@ else {
$global:EPTitle = $global:EPTitle.ToUpper()
}
$global:EPTitle = $global:EPTitle -replace '"', '""'
$optimalFontSize = Get-OptimalPointSize -text $global:EPTitle -font $TitleCardfontImagemagick -box_width $TitleCardEPTitleMaxWidth -box_height $TitleCardEPTitleMaxHeight -min_pointsize $TitleCardEPTitleminPointSize -max_pointsize $TitleCardEPTitlemaxPointSize
$joinedTitlePointSize = $global:EPTitle -replace '""', '""""'
$optimalFontSize = Get-OptimalPointSize -text $joinedTitlePointSize -font $TitleCardfontImagemagick -box_width $TitleCardEPTitleMaxWidth -box_height $TitleCardEPTitleMaxHeight -min_pointsize $TitleCardEPTitleminPointSize -max_pointsize $TitleCardEPTitlemaxPointSize
if (!$global:IsTruncated) {
Write-Entry -Subtext "Optimal font size set to: '$optimalFontSize'" -Path $global:ScriptRoot\Logs\Scriptlog.log -Color White -log Info

Expand All @@ -6308,7 +6317,8 @@ else {
$global:SeasonEPNumber = $global:SeasonEPNumber.ToUpper()
}
$global:SeasonEPNumber = $global:SeasonEPNumber -replace '"', '""'
$optimalFontSize = Get-OptimalPointSize -text $global:SeasonEPNumber -font $TitleCardfontImagemagick -box_width $TitleCardEPMaxWidth -box_height $TitleCardEPMaxHeight -min_pointsize $TitleCardEPminPointSize -max_pointsize $TitleCardEPmaxPointSize
$joinedTitlePointSize = $global:SeasonEPNumber -replace '""', '""""'
$optimalFontSize = Get-OptimalPointSize -text $joinedTitlePointSize -font $TitleCardfontImagemagick -box_width $TitleCardEPMaxWidth -box_height $TitleCardEPMaxHeight -min_pointsize $TitleCardEPminPointSize -max_pointsize $TitleCardEPmaxPointSize
if (!$global:IsTruncated) {
Write-Entry -Subtext "Optimal font size set to: '$optimalFontSize'" -Path $global:ScriptRoot\Logs\Scriptlog.log -Color White -log Info

Expand Down
2 changes: 1 addition & 1 deletion Release.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.67
1.0.68

0 comments on commit 5822cc8

Please sign in to comment.