Initial commit
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
using ImageMagick;
|
||||
using PosterMaker.Interfaces.Services;
|
||||
using PosterMaker.Models;
|
||||
|
||||
namespace PosterMaker.Services;
|
||||
|
||||
public class CollectionPosterMakerService : ICollectionPosterMakerService
|
||||
{
|
||||
private static readonly string RefDir = Path.Combine("Resources", "Collections");
|
||||
private static readonly string RefDirectory = Path.Combine(Directory.GetCurrentDirectory(), RefDir);
|
||||
private static readonly string TitleFont = Path.Combine(RefDirectory, "Arial Bold.ttf");
|
||||
private static readonly string CollectionFont = Path.Combine(RefDirectory, "MyriadRegular.ttf");
|
||||
private static readonly string Gradient = Path.Combine(RefDirectory, "gradient.png");
|
||||
private static readonly string Frame = Path.Combine(RefDirectory, "frame.png");
|
||||
|
||||
private const string FontColor = "white";
|
||||
private const float FontSize = 1.0F;
|
||||
|
||||
public CollectionPosterMakerService()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public byte[] CreatePoster(string file, ImageProperties imageProperties)
|
||||
{
|
||||
using var image = new MagickImage(file);
|
||||
var resizeGeometry = new MagickGeometry(1892, 2892)
|
||||
{
|
||||
FillArea = true
|
||||
};
|
||||
image.Resize(resizeGeometry);
|
||||
image.Extent(2000, 3000, Gravity.Center);
|
||||
|
||||
ApplyGradient(image);
|
||||
using var frame = new MagickImage(Frame);
|
||||
frame.BackgroundColor = new MagickColor("transparent");
|
||||
image.Composite(frame, Gravity.Center, CompositeOperator.Over);
|
||||
|
||||
//AddLogo(image, imageProperties.Logo, imageProperties.LogoOption);
|
||||
AddTitle(image, imageProperties);
|
||||
image.Resize(new Percentage(50));
|
||||
return image.ToByteArray();
|
||||
}
|
||||
|
||||
private static void ApplyGradient(MagickImage image)
|
||||
{
|
||||
using var gradient = new MagickImage(Gradient);
|
||||
image.Composite(gradient, Gravity.Center, CompositeOperator.Multiply);
|
||||
}
|
||||
|
||||
private void AddTitle(MagickImage image, ImageProperties properties)
|
||||
{
|
||||
if (string.IsNullOrEmpty(properties.Title))
|
||||
return;
|
||||
|
||||
var readSettings = new MagickReadSettings
|
||||
{
|
||||
BackgroundColor = MagickColors.Transparent,
|
||||
FillColor = new MagickColor(FontColor),
|
||||
Font = TitleFont,
|
||||
FontPointsize = 180 * FontSize,
|
||||
TextGravity = Gravity.Center,
|
||||
TextKerning = 2
|
||||
};
|
||||
|
||||
var labelImages = new MagickImageCollection();
|
||||
if (!string.IsNullOrEmpty(properties.Title))
|
||||
{
|
||||
labelImages.Add(new MagickImage($"label:{properties.Title.ToUpper()}", readSettings));
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(properties.Title2))
|
||||
{
|
||||
labelImages.Add(new MagickImage($"label:{properties.Title2.ToUpper()}", readSettings));
|
||||
}
|
||||
readSettings.FontPointsize = 70;
|
||||
readSettings.TextKerning = 50;
|
||||
readSettings.Font = CollectionFont;
|
||||
|
||||
labelImages.Add(new MagickImage($"label:COLLECTION", readSettings));
|
||||
using var labels = labelImages.SmushVertical(44);
|
||||
image.Composite(labels, Gravity.South, 0, 266, CompositeOperator.Atop);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
using ImageMagick;
|
||||
using PosterMaker.Interfaces.Services;
|
||||
using PosterMaker.Models.Enums;
|
||||
|
||||
namespace PosterMaker.Services;
|
||||
|
||||
public class MovieLogoService : IMovieLogoService
|
||||
{
|
||||
private static readonly string LogoDir = Path.Combine("Resources", "Logos");
|
||||
private static readonly string StudioDir = Path.Combine(LogoDir, "Studio");
|
||||
private static readonly string NetworkDir = Path.Combine(LogoDir, "Network");
|
||||
|
||||
public byte[]? GetMovieLogo(MovieLogoEnum? logo)
|
||||
{
|
||||
if (logo == null) return null;
|
||||
var logoPath = Path.Combine(StudioDir, GetFileForLogo(logo));
|
||||
return File.ReadAllBytes(logoPath);;
|
||||
}
|
||||
|
||||
public byte[]? GetNetworkLogo(NetworkLogoEnum? logo)
|
||||
{
|
||||
if (logo == null) return null;
|
||||
var logoPath = Path.Combine(NetworkDir, GetFileForNetworkLogo(logo));
|
||||
return File.ReadAllBytes(logoPath);
|
||||
}
|
||||
|
||||
public Gravity GetLogoGravity(MovieLogoEnum? imagePropertiesLogo)
|
||||
{
|
||||
return imagePropertiesLogo switch
|
||||
{
|
||||
MovieLogoEnum.Disney => Gravity.North,
|
||||
MovieLogoEnum.DC => Gravity.North,
|
||||
MovieLogoEnum.SonyPicturesAnimation => Gravity.North,
|
||||
MovieLogoEnum.MarvelStudios => Gravity.North,
|
||||
MovieLogoEnum.A24 => Gravity.Northwest,
|
||||
MovieLogoEnum.Dreamworks => Gravity.North,
|
||||
MovieLogoEnum.DisneyPixar => Gravity.North,
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(imagePropertiesLogo), imagePropertiesLogo, null)
|
||||
};
|
||||
}
|
||||
|
||||
public MagickGeometry GetLogoGeometry(MovieLogoEnum? logoEnum)
|
||||
{
|
||||
var defaultGeometry = new MagickGeometry(200, 100);
|
||||
return logoEnum switch
|
||||
{
|
||||
MovieLogoEnum.Disney => defaultGeometry,
|
||||
MovieLogoEnum.DC => defaultGeometry,
|
||||
MovieLogoEnum.SonyPicturesAnimation => defaultGeometry,
|
||||
MovieLogoEnum.MarvelStudios => defaultGeometry,
|
||||
MovieLogoEnum.A24 => defaultGeometry,
|
||||
MovieLogoEnum.Dreamworks => defaultGeometry,
|
||||
MovieLogoEnum.DisneyPixar => new MagickGeometry(520, 100),
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(logoEnum), logoEnum, null)
|
||||
};
|
||||
}
|
||||
|
||||
public int GetNetworkLogoHeight(NetworkLogoEnum? logo)
|
||||
{
|
||||
return logo switch
|
||||
{
|
||||
NetworkLogoEnum.Hulu => 150,
|
||||
NetworkLogoEnum.Netflix => 200,
|
||||
NetworkLogoEnum.ParamountPlus => 200,
|
||||
_ => 150
|
||||
};
|
||||
}
|
||||
|
||||
private string GetFileForLogo(MovieLogoEnum? logo)
|
||||
{
|
||||
return logo switch
|
||||
{
|
||||
MovieLogoEnum.Disney => "Disney.svg",
|
||||
MovieLogoEnum.DC => "DC.svg",
|
||||
MovieLogoEnum.SonyPicturesAnimation => "Sony_Pictures_Animation.svg",
|
||||
MovieLogoEnum.MarvelStudios => "Marvel_Studios.svg",
|
||||
MovieLogoEnum.A24 => "A24.svg",
|
||||
MovieLogoEnum.Dreamworks => "Dreamworks.svg",
|
||||
MovieLogoEnum.DisneyPixar => "DisneyPixar.svg",
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(logo), logo, null)
|
||||
};
|
||||
}
|
||||
|
||||
private string GetFileForNetworkLogo(NetworkLogoEnum? logo)
|
||||
{
|
||||
return logo switch
|
||||
{
|
||||
NetworkLogoEnum.Netflix => "Netflix.svg",
|
||||
NetworkLogoEnum.DisneyPlus => "DisneyPlus.svg",
|
||||
NetworkLogoEnum.AppleTv => "AppleTv.png",
|
||||
NetworkLogoEnum.Hbo => "HBO.svg",
|
||||
NetworkLogoEnum.Fxx => "FXX.svg",
|
||||
NetworkLogoEnum.Cbs => "CBS.svg",
|
||||
NetworkLogoEnum.Peacock => "Peacock.svg",
|
||||
NetworkLogoEnum.AmazonPrimeVideo => "AmazonPrimeVideo.png",
|
||||
NetworkLogoEnum.Nbc => "NBC.svg",
|
||||
NetworkLogoEnum.Amc => "AMC.svg",
|
||||
NetworkLogoEnum.Starz => "Starz.svg",
|
||||
NetworkLogoEnum.Hulu => "Hulu.svg",
|
||||
NetworkLogoEnum.Cw => "CW.svg",
|
||||
NetworkLogoEnum.ParamountPlus => "ParamountPlus.svg",
|
||||
NetworkLogoEnum.ComedyCentral => "ComedyCentral.svg",
|
||||
NetworkLogoEnum.Abc => "ABC.svg",
|
||||
NetworkLogoEnum.Bbc => "BBC.svg",
|
||||
NetworkLogoEnum.Usa => "USA.svg",
|
||||
NetworkLogoEnum.Tbs => "TBS.svg",
|
||||
NetworkLogoEnum.Fx => "FX.svg",
|
||||
NetworkLogoEnum.AdultSwim => "AdultSwim.svg",
|
||||
NetworkLogoEnum.Max => "Max.svg",
|
||||
NetworkLogoEnum.Mtv => "MTV.svg",
|
||||
NetworkLogoEnum.ChannelFour => "ChannelFour.png",
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(logo), logo, null)
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
using ImageMagick;
|
||||
using PosterMaker.Interfaces.Services;
|
||||
using PosterMaker.Models;
|
||||
using PosterMaker.Models.Enums;
|
||||
|
||||
namespace PosterMaker.Services;
|
||||
|
||||
public class MoviePosterMakerService : IMoviePosterMakerService
|
||||
{
|
||||
private static readonly string RefDir = Path.Combine("Resources", "Movies");
|
||||
private static readonly string RefDirectory = Path.Combine(Directory.GetCurrentDirectory(), RefDir);
|
||||
private static readonly string Font = Path.Combine(RefDirectory, "Arial Bold.ttf");
|
||||
private static readonly string Frame = Path.Combine(RefDirectory, "frame.png");
|
||||
private static readonly string Gradient = Path.Combine(RefDirectory, "gradient.png");
|
||||
|
||||
private const string FontColor = "white";
|
||||
private const float FontSize = 1.0F;
|
||||
private const string IndexFontColor = "rgb(154,154,154)";
|
||||
|
||||
private readonly IMovieLogoService _movieLogoService;
|
||||
|
||||
public MoviePosterMakerService(IMovieLogoService movieLogoService)
|
||||
{
|
||||
_movieLogoService = movieLogoService;
|
||||
}
|
||||
|
||||
public byte[] CreatePoster(string file, ImageProperties imageProperties)
|
||||
{
|
||||
using var image = new MagickImage(file);
|
||||
var resizeGeometry = new MagickGeometry(1892, 2892)
|
||||
{
|
||||
FillArea = true
|
||||
};
|
||||
image.Resize(resizeGeometry);
|
||||
image.Extent(2000, 3000, Gravity.Center);
|
||||
|
||||
ApplyGradient(image);
|
||||
|
||||
using var frame = new MagickImage(Frame);
|
||||
frame.BackgroundColor = new MagickColor("transparent");
|
||||
image.Composite(frame, Gravity.Center, CompositeOperator.Over);
|
||||
|
||||
AddLogo(image, imageProperties.Logo, imageProperties.LogoOption);
|
||||
AddIndex(image, imageProperties.Index);
|
||||
AddTitle(image, imageProperties);
|
||||
|
||||
return image.ToByteArray();
|
||||
}
|
||||
|
||||
private static void ApplyGradient(MagickImage image)
|
||||
{
|
||||
using var gradient = new MagickImage(Gradient);
|
||||
image.Composite(gradient, Gravity.Center, CompositeOperator.Multiply);
|
||||
}
|
||||
|
||||
private static void AddIndex(MagickImage image, string? input)
|
||||
{
|
||||
if (string.IsNullOrEmpty(input)) return;
|
||||
var readSettings = new MagickReadSettings
|
||||
{
|
||||
Font = Font,
|
||||
FillColor = new MagickColor(IndexFontColor),
|
||||
FontPointsize = 598,
|
||||
TextGravity = Gravity.Center,
|
||||
BackgroundColor = MagickColors.Transparent,
|
||||
};
|
||||
var index = new MagickImage($"label:{(input)}", readSettings);
|
||||
image.Composite(index, Gravity.South, 0, 50, CompositeOperator.Atop);
|
||||
}
|
||||
|
||||
private void AddLogo(MagickImage image, MovieLogoEnum? logo, LogoOptionEnum? logoOptionEnum)
|
||||
{
|
||||
if (logo == null) return;
|
||||
var logoFile = _movieLogoService.GetMovieLogo(logo);
|
||||
var gravity = _movieLogoService.GetLogoGravity(logo);
|
||||
var readSettings = new MagickReadSettings
|
||||
{
|
||||
TextGravity = Gravity.Center,
|
||||
BackgroundColor = MagickColors.Transparent
|
||||
};
|
||||
using var logoImage = new MagickImage(logoFile, readSettings);
|
||||
logoImage.Resize(_movieLogoService.GetLogoGeometry(logo));
|
||||
|
||||
if (logoOptionEnum == LogoOptionEnum.White)
|
||||
{
|
||||
logoImage.Colorize(MagickColors.White, new Percentage(100));
|
||||
}
|
||||
if (logoOptionEnum == LogoOptionEnum.Black)
|
||||
{
|
||||
logoImage.Colorize(MagickColors.Black, new Percentage(100));
|
||||
}
|
||||
var shadow = new MagickImage(logoImage);
|
||||
shadow.Shadow(3, 3,3, new Percentage(80));
|
||||
var offset = gravity == Gravity.Northwest ? 100 : 0;
|
||||
image.Composite(shadow, gravity, offset, 100, CompositeOperator.Atop);
|
||||
|
||||
image.Composite(logoImage, gravity, offset, 100, CompositeOperator.Atop);
|
||||
}
|
||||
|
||||
private void AddTitle(MagickImage image, ImageProperties properties)
|
||||
{
|
||||
if (string.IsNullOrEmpty(properties.TopSubtitle) && string.IsNullOrEmpty(properties.Title) && string.IsNullOrEmpty(properties.Subtitle))
|
||||
return;
|
||||
|
||||
var readSettings = new MagickReadSettings
|
||||
{
|
||||
BackgroundColor = MagickColors.Transparent,
|
||||
FillColor = new MagickColor(FontColor),
|
||||
Font = Font,
|
||||
Debug = true
|
||||
};
|
||||
|
||||
var labelImages = new MagickImageCollection();
|
||||
if (!string.IsNullOrEmpty(properties.TopSubtitle))
|
||||
{
|
||||
readSettings.FontPointsize = 95 * FontSize;
|
||||
readSettings.TextGravity = Gravity.Center;
|
||||
labelImages.Add(new MagickImage($"label:{properties.TopSubtitle.ToUpper()}", readSettings));
|
||||
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(properties.Title))
|
||||
{
|
||||
readSettings.FontPointsize = 190 * FontSize;
|
||||
readSettings.TextKerning = 0.7;
|
||||
readSettings.TextInterlineSpacing = -44.5;
|
||||
readSettings.TextInterwordSpacing = 55;
|
||||
readSettings.TextGravity = Gravity.Center;
|
||||
labelImages.Add(new MagickImage($"label:{properties.Title.ToUpper()}", readSettings));
|
||||
}
|
||||
if (!string.IsNullOrEmpty(properties.Title2))
|
||||
{
|
||||
readSettings.FontPointsize = 190 * FontSize;
|
||||
readSettings.TextKerning = 0.7;
|
||||
readSettings.TextInterlineSpacing = -44.5;
|
||||
readSettings.TextInterwordSpacing = 55;
|
||||
readSettings.TextGravity = Gravity.Center;
|
||||
labelImages.Add(new MagickImage($"label:{properties.Title2.ToUpper()}", readSettings));
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(properties.Subtitle))
|
||||
{
|
||||
readSettings.FontPointsize = 95 * FontSize;
|
||||
readSettings.TextInterwordSpacing = 18;
|
||||
readSettings.TextKerning = 0.5;
|
||||
readSettings.TextGravity = Gravity.Center;
|
||||
labelImages.Add(new MagickImage($"label:{properties.Subtitle.ToUpper()}", readSettings));
|
||||
}
|
||||
|
||||
using var labels = labelImages.SmushVertical(30);
|
||||
var titleHeight = !string.IsNullOrEmpty(properties.Subtitle) ? 182 : 262;
|
||||
image.Composite(labels, Gravity.South, 0, titleHeight, CompositeOperator.Atop);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,215 @@
|
||||
using ImageMagick;
|
||||
using PosterMaker.Interfaces.Services;
|
||||
using PosterMaker.Models;
|
||||
using PosterMaker.Models.Enums;
|
||||
|
||||
namespace PosterMaker.Services;
|
||||
|
||||
public class SeriesPosterMakerService : ISeriesPosterMakerService
|
||||
{
|
||||
private static readonly string RefDir = Path.Combine("Resources", "Series");
|
||||
private static readonly string RefDirectory = Path.Combine(Directory.GetCurrentDirectory(), RefDir);
|
||||
private static readonly string Font = Path.Combine(RefDirectory, "Arial Bold.ttf");
|
||||
private static readonly string SeasonFont = Path.Combine(RefDirectory, "Proxima Nova Semibold.ttf");
|
||||
private static readonly string Frame = Path.Combine(RefDirectory, "frame.png");
|
||||
private static readonly string Gradient = Path.Combine(RefDirectory, "gradient.png");
|
||||
|
||||
private const string FontColor = "white";
|
||||
private const float FontSize = 1.0F;
|
||||
|
||||
private readonly IMovieLogoService _movieLogoService;
|
||||
|
||||
public SeriesPosterMakerService(IMovieLogoService movieLogoService)
|
||||
{
|
||||
_movieLogoService = movieLogoService;
|
||||
}
|
||||
|
||||
public byte[] CreatePoster(string file, ImageProperties imageProperties)
|
||||
{
|
||||
using var image = new MagickImage(file);
|
||||
var resizeGeometry = new MagickGeometry(1892, 2892)
|
||||
{
|
||||
FillArea = true
|
||||
};
|
||||
image.Resize(resizeGeometry);
|
||||
image.Extent(2000, 3000, Gravity.Center);
|
||||
|
||||
ApplyGradient(image);
|
||||
|
||||
using var frame = new MagickImage(Frame);
|
||||
frame.BackgroundColor = new MagickColor("transparent");
|
||||
image.Composite(frame, Gravity.Center, CompositeOperator.Over);
|
||||
|
||||
AddStudioLogo(image, imageProperties.Logo, imageProperties.LogoOption);
|
||||
AddNetworkLogo(image, imageProperties.NetworkLogo, imageProperties.LogoOption);
|
||||
AddTitle(image, imageProperties);
|
||||
|
||||
return image.ToByteArray();
|
||||
}
|
||||
|
||||
private static void ApplyGradient(MagickImage image)
|
||||
{
|
||||
using var gradient = new MagickImage(Gradient);
|
||||
image.Composite(gradient, Gravity.Center, CompositeOperator.Multiply);
|
||||
}
|
||||
|
||||
private void AddStudioLogo(MagickImage image, MovieLogoEnum? logo, LogoOptionEnum? logoOptionEnum)
|
||||
{
|
||||
if (logo == null) return;
|
||||
var logoFile = _movieLogoService.GetMovieLogo(logo);
|
||||
var gravity = _movieLogoService.GetLogoGravity(logo);
|
||||
var readSettings = new MagickReadSettings
|
||||
{
|
||||
TextGravity = Gravity.Center,
|
||||
BackgroundColor = MagickColors.Transparent
|
||||
};
|
||||
using var logoImage = new MagickImage(logoFile, readSettings);
|
||||
logoImage.Resize(new MagickGeometry(500, 250));
|
||||
|
||||
switch (logoOptionEnum)
|
||||
{
|
||||
case LogoOptionEnum.White:
|
||||
logoImage.Colorize(MagickColors.White, new Percentage(100));
|
||||
break;
|
||||
case LogoOptionEnum.Black:
|
||||
logoImage.Colorize(MagickColors.Black, new Percentage(100));
|
||||
break;
|
||||
}
|
||||
|
||||
var offset = gravity == Gravity.Northwest ? 100 : 0;
|
||||
image.Composite(logoImage, gravity, offset, 100, CompositeOperator.Atop);
|
||||
}
|
||||
|
||||
private void AddNetworkLogo(MagickImage image, NetworkLogoEnum? logo, LogoOptionEnum? logoOptionEnum)
|
||||
{
|
||||
if (logo == null) return;
|
||||
var logoFile = _movieLogoService.GetNetworkLogo(logo);
|
||||
var readSettings = new MagickReadSettings
|
||||
{
|
||||
TextGravity = Gravity.Center,
|
||||
BackgroundColor = MagickColors.Transparent
|
||||
};
|
||||
using var logoImage = new MagickImage(logoFile, readSettings);
|
||||
var networkLogoHeight = _movieLogoService.GetNetworkLogoHeight(logo);
|
||||
logoImage.Resize(new MagickGeometry(networkLogoHeight * 2, networkLogoHeight));
|
||||
|
||||
|
||||
switch (logoOptionEnum)
|
||||
{
|
||||
case LogoOptionEnum.White:
|
||||
logoImage.Colorize(MagickColors.White, new Percentage(100));
|
||||
break;
|
||||
case LogoOptionEnum.Black:
|
||||
logoImage.Colorize(MagickColors.Black, new Percentage(100));
|
||||
break;
|
||||
}
|
||||
var shadow = new MagickImage(logoImage);
|
||||
shadow.Shadow(2, 2,3, new Percentage(80));
|
||||
switch (logoOptionEnum)
|
||||
{
|
||||
case LogoOptionEnum.White:
|
||||
shadow.Colorize(MagickColors.Black, new Percentage(100));
|
||||
break;
|
||||
case LogoOptionEnum.Black:
|
||||
shadow.Colorize(MagickColors.White, new Percentage(100));
|
||||
break;
|
||||
}
|
||||
image.Composite(shadow, Gravity.Northwest, 100, 100, CompositeOperator.Atop);
|
||||
image.Composite(logoImage, Gravity.Northwest, 100, 100, CompositeOperator.Atop);
|
||||
}
|
||||
|
||||
private void AddTitle(MagickImage image, ImageProperties properties)
|
||||
{
|
||||
if (string.IsNullOrEmpty(properties.TopSubtitle) && string.IsNullOrEmpty(properties.Title) &&
|
||||
string.IsNullOrEmpty(properties.Subtitle) && string.IsNullOrEmpty(properties.Season))
|
||||
return;
|
||||
|
||||
var readSettings = new MagickReadSettings
|
||||
{
|
||||
BackgroundColor = MagickColors.Transparent,
|
||||
FillColor = new MagickColor(FontColor),
|
||||
Font = Font,
|
||||
Debug = true
|
||||
};
|
||||
|
||||
var labelImages = new MagickImageCollection();
|
||||
if (!string.IsNullOrEmpty(properties.TopSubtitle))
|
||||
{
|
||||
readSettings.FontPointsize = 95 * FontSize;
|
||||
readSettings.TextGravity = Gravity.Center;
|
||||
labelImages.Add(new MagickImage($"label:{properties.TopSubtitle.ToUpper()}", readSettings));
|
||||
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(properties.Title))
|
||||
{
|
||||
readSettings.FontPointsize = 190 * FontSize;
|
||||
readSettings.TextKerning = 0.7;
|
||||
readSettings.TextInterlineSpacing = -44.5;
|
||||
readSettings.TextInterwordSpacing = 55;
|
||||
readSettings.TextGravity = Gravity.Center;
|
||||
labelImages.Add(new MagickImage($"label:{properties.Title.ToUpper()}", readSettings));
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(properties.Title2))
|
||||
{
|
||||
readSettings.FontPointsize = 190 * FontSize;
|
||||
readSettings.TextKerning = 0.7;
|
||||
readSettings.TextInterlineSpacing = -44.5;
|
||||
readSettings.TextInterwordSpacing = 55;
|
||||
readSettings.TextGravity = Gravity.Center;
|
||||
labelImages.Add(new MagickImage($"label:{properties.Title2.ToUpper()}", readSettings));
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(properties.Subtitle))
|
||||
{
|
||||
readSettings.FontPointsize = 95 * FontSize;
|
||||
readSettings.TextInterwordSpacing = 18;
|
||||
readSettings.TextKerning = 0.5;
|
||||
readSettings.TextGravity = Gravity.Center;
|
||||
labelImages.Add(new MagickImage($"label:{properties.Subtitle.ToUpper()}", readSettings));
|
||||
}
|
||||
|
||||
using var labels = labelImages.SmushVertical(30);
|
||||
var seasonImages = new MagickImageCollection();
|
||||
var image2 = new MagickImage();
|
||||
if (!string.IsNullOrEmpty(properties.Season) && ((properties.LimitedSeries != null && properties.LimitedSeries != true) || properties.LimitedSeries == null))
|
||||
{
|
||||
seasonImages.Add(labels);
|
||||
readSettings.TextInterlineSpacing = 150;
|
||||
readSettings.FontPointsize = 66 * FontSize;
|
||||
readSettings.TextGravity = Gravity.Center;
|
||||
readSettings.TextKerning = 50;
|
||||
readSettings.TextInterwordSpacing = 20;
|
||||
readSettings.Font = SeasonFont;
|
||||
var seasonImage = new MagickImage($"label:SEASON {properties.Season.ToUpper()}", readSettings);
|
||||
seasonImages.Add(seasonImage);
|
||||
var offset = string.IsNullOrEmpty(properties.Subtitle) ? 150 : 75;
|
||||
using var imageWithSeason = seasonImages.SmushVertical(offset);
|
||||
image2 = new MagickImage(imageWithSeason);
|
||||
}
|
||||
|
||||
if (properties.LimitedSeries == true)
|
||||
{
|
||||
seasonImages.Add(labels);
|
||||
readSettings.TextInterlineSpacing = 150;
|
||||
readSettings.FontPointsize = 66 * FontSize;
|
||||
readSettings.TextGravity = Gravity.Center;
|
||||
readSettings.TextKerning = 50;
|
||||
readSettings.TextInterwordSpacing = 20;
|
||||
readSettings.Font = SeasonFont;
|
||||
var seasonImage = new MagickImage($"label:LIMITED SERIES", readSettings);
|
||||
seasonImages.Add(seasonImage);
|
||||
using var imageWithSeason = seasonImages.SmushVertical(150);
|
||||
image2 = new MagickImage(imageWithSeason);
|
||||
}
|
||||
|
||||
var titleHeight = !string.IsNullOrEmpty(properties.Season) || properties.LimitedSeries == true ? 85 : 262;
|
||||
if (!string.IsNullOrEmpty(properties.Subtitle) && properties.LimitedSeries is not true && string.IsNullOrWhiteSpace(properties.Season))
|
||||
{
|
||||
titleHeight = 200;
|
||||
}
|
||||
|
||||
image.Composite(string.IsNullOrEmpty(properties.Season) && properties.LimitedSeries != true ? labels : image2, Gravity.South, 0, titleHeight, CompositeOperator.Atop);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user