mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-04-20 17:14:42 +01:00
added drawing project
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using MediaBrowser.Common.Configuration;
|
||||
using MediaBrowser.Common.IO;
|
||||
using MediaBrowser.Controller.Drawing;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.Audio;
|
||||
using MediaBrowser.Controller.Entities.TV;
|
||||
@@ -22,8 +23,7 @@ namespace MediaBrowser.Server.Implementations.UserViews
|
||||
private readonly IUserManager _userManager;
|
||||
private readonly ILibraryManager _libraryManager;
|
||||
|
||||
public DynamicImageProvider(IFileSystem fileSystem, IProviderManager providerManager, IApplicationPaths applicationPaths, IUserManager userManager, ILibraryManager libraryManager)
|
||||
: base(fileSystem, providerManager, applicationPaths)
|
||||
public DynamicImageProvider(IFileSystem fileSystem, IProviderManager providerManager, IApplicationPaths applicationPaths, IImageProcessor imageProcessor, IUserManager userManager, ILibraryManager libraryManager) : base(fileSystem, providerManager, applicationPaths, imageProcessor)
|
||||
{
|
||||
_userManager = userManager;
|
||||
_libraryManager = libraryManager;
|
||||
@@ -238,7 +238,7 @@ namespace MediaBrowser.Server.Implementations.UserViews
|
||||
return collectionStripViewTypes.Contains(view.ViewType ?? string.Empty);
|
||||
}
|
||||
|
||||
protected override async Task<Stream> CreateImageAsync(IHasImages item, List<BaseItem> itemsWithImages, ImageType imageType, int imageIndex)
|
||||
protected override Stream CreateImageAsync(IHasImages item, List<BaseItem> itemsWithImages, ImageType imageType, int imageIndex)
|
||||
{
|
||||
var view = (UserView)item;
|
||||
if (imageType == ImageType.Primary && IsUsingCollectionStrip(view))
|
||||
@@ -248,15 +248,17 @@ namespace MediaBrowser.Server.Implementations.UserViews
|
||||
return null;
|
||||
}
|
||||
|
||||
return new StripCollageBuilder(ApplicationPaths).BuildThumbCollage(GetStripCollageImagePaths(itemsWithImages, view.ViewType), 960, 540, false, item.Name);
|
||||
return GetThumbCollage(item, itemsWithImages, 960, 540, false, item.Name);
|
||||
}
|
||||
|
||||
return await base.CreateImageAsync(item, itemsWithImages, imageType, imageIndex);
|
||||
return base.CreateImageAsync(item, itemsWithImages, imageType, imageIndex);
|
||||
}
|
||||
|
||||
private IEnumerable<String> GetStripCollageImagePaths(IEnumerable<BaseItem> items, string viewType)
|
||||
protected override IEnumerable<String> GetStripCollageImagePaths(IHasImages primaryItem, IEnumerable<BaseItem> items)
|
||||
{
|
||||
if (string.Equals(viewType, CollectionType.LiveTv, StringComparison.OrdinalIgnoreCase))
|
||||
var userView = primaryItem as UserView;
|
||||
|
||||
if (userView != null && string.Equals(userView.ViewType, CollectionType.LiveTv, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
var list = new List<string>();
|
||||
for (int i = 1; i <= 8; i++)
|
||||
@@ -266,9 +268,7 @@ namespace MediaBrowser.Server.Implementations.UserViews
|
||||
return list;
|
||||
}
|
||||
|
||||
return items
|
||||
.Select(i => i.GetImagePath(ImageType.Primary) ?? i.GetImagePath(ImageType.Thumb))
|
||||
.Where(i => !string.IsNullOrWhiteSpace(i));
|
||||
return base.GetStripCollageImagePaths(primaryItem, items);
|
||||
}
|
||||
|
||||
private string ExtractLiveTvResource(string name, IApplicationPaths paths)
|
||||
|
||||
@@ -1,512 +0,0 @@
|
||||
using ImageMagickSharp;
|
||||
using MediaBrowser.Common.Configuration;
|
||||
using MediaBrowser.Server.Implementations.Drawing;
|
||||
using MediaBrowser.Server.Implementations.Photos;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace MediaBrowser.Server.Implementations.UserViews
|
||||
{
|
||||
public class StripCollageBuilder
|
||||
{
|
||||
private readonly IApplicationPaths _appPaths;
|
||||
|
||||
public StripCollageBuilder(IApplicationPaths appPaths)
|
||||
{
|
||||
_appPaths = appPaths;
|
||||
}
|
||||
|
||||
public Stream BuildPosterCollage(IEnumerable<string> paths, int width, int height, bool renderWithText, string text)
|
||||
{
|
||||
if (renderWithText)
|
||||
{
|
||||
using (var wand = BuildPosterCollageWandWithText(paths, text, width, height))
|
||||
{
|
||||
return DynamicImageHelpers.GetStream(wand, _appPaths);
|
||||
}
|
||||
}
|
||||
using (var wand = BuildPosterCollageWand(paths, width, height))
|
||||
{
|
||||
return DynamicImageHelpers.GetStream(wand, _appPaths);
|
||||
}
|
||||
}
|
||||
|
||||
public Stream BuildSquareCollage(IEnumerable<string> paths, int width, int height, bool renderWithText, string text)
|
||||
{
|
||||
if (renderWithText)
|
||||
{
|
||||
using (var wand = BuildSquareCollageWandWithText(paths, text, width, height))
|
||||
{
|
||||
return DynamicImageHelpers.GetStream(wand, _appPaths);
|
||||
}
|
||||
}
|
||||
using (var wand = BuildSquareCollageWand(paths, width, height))
|
||||
{
|
||||
return DynamicImageHelpers.GetStream(wand, _appPaths);
|
||||
}
|
||||
}
|
||||
|
||||
public Stream BuildThumbCollage(IEnumerable<string> paths, int width, int height, bool renderWithText, string text)
|
||||
{
|
||||
if (renderWithText)
|
||||
{
|
||||
using (var wand = BuildThumbCollageWandWithText(paths, text, width, height))
|
||||
{
|
||||
return DynamicImageHelpers.GetStream(wand, _appPaths);
|
||||
}
|
||||
}
|
||||
using (var wand = BuildThumbCollageWand(paths, width, height))
|
||||
{
|
||||
return DynamicImageHelpers.GetStream(wand, _appPaths);
|
||||
}
|
||||
}
|
||||
|
||||
private string[] ProjectPaths(IEnumerable<string> paths, int count)
|
||||
{
|
||||
var clone = paths.ToList();
|
||||
var list = new List<string>();
|
||||
|
||||
while (list.Count < count)
|
||||
{
|
||||
foreach (var path in clone)
|
||||
{
|
||||
list.Add(path);
|
||||
|
||||
if (list.Count >= count)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return list.Take(count).ToArray();
|
||||
}
|
||||
|
||||
private MagickWand BuildThumbCollageWandWithText(IEnumerable<string> paths, string text, int width, int height)
|
||||
{
|
||||
var inputPaths = ProjectPaths(paths, 8);
|
||||
using (var wandImages = new MagickWand(inputPaths))
|
||||
{
|
||||
var wand = new MagickWand(width, height);
|
||||
wand.OpenImage("gradient:#111111-#111111");
|
||||
using (var draw = new DrawingWand())
|
||||
{
|
||||
using (var fcolor = new PixelWand(ColorName.White))
|
||||
{
|
||||
draw.FillColor = fcolor;
|
||||
draw.Font = MontserratLightFont;
|
||||
draw.FontSize = 60;
|
||||
draw.FontWeight = FontWeightType.LightStyle;
|
||||
draw.TextAntialias = true;
|
||||
}
|
||||
|
||||
var fontMetrics = wand.QueryFontMetrics(draw, text);
|
||||
var textContainerY = Convert.ToInt32(height * .165);
|
||||
wand.CurrentImage.AnnotateImage(draw, (width - fontMetrics.TextWidth) / 2, textContainerY, 0.0, text);
|
||||
|
||||
var iSlice = Convert.ToInt32(width * .1166666667);
|
||||
int iTrans = Convert.ToInt32(height * 0.2);
|
||||
int iHeight = Convert.ToInt32(height * 0.46296296296296296296296296296296);
|
||||
var horizontalImagePadding = Convert.ToInt32(width * 0.0125);
|
||||
|
||||
foreach (var element in wandImages.ImageList)
|
||||
{
|
||||
int iWidth = (int)Math.Abs(iHeight * element.Width / element.Height);
|
||||
element.Gravity = GravityType.CenterGravity;
|
||||
element.BackgroundColor = new PixelWand("none", 1);
|
||||
element.ResizeImage(iWidth, iHeight, FilterTypes.LanczosFilter);
|
||||
int ix = (int)Math.Abs((iWidth - iSlice) / 2);
|
||||
element.CropImage(iSlice, iHeight, ix, 0);
|
||||
|
||||
element.ExtentImage(iSlice, iHeight, 0 - horizontalImagePadding, 0);
|
||||
}
|
||||
|
||||
wandImages.SetFirstIterator();
|
||||
using (var wandList = wandImages.AppendImages())
|
||||
{
|
||||
wandList.CurrentImage.TrimImage(1);
|
||||
using (var mwr = wandList.CloneMagickWand())
|
||||
{
|
||||
using (var blackPixelWand = new PixelWand(ColorName.Black))
|
||||
{
|
||||
using (var greyPixelWand = new PixelWand(ColorName.Grey70))
|
||||
{
|
||||
mwr.CurrentImage.ResizeImage(wandList.CurrentImage.Width, (wandList.CurrentImage.Height / 2), FilterTypes.LanczosFilter, 1);
|
||||
mwr.CurrentImage.FlipImage();
|
||||
|
||||
mwr.CurrentImage.AlphaChannel = AlphaChannelType.DeactivateAlphaChannel;
|
||||
mwr.CurrentImage.ColorizeImage(blackPixelWand, greyPixelWand);
|
||||
|
||||
using (var mwg = new MagickWand(wandList.CurrentImage.Width, iTrans))
|
||||
{
|
||||
mwg.OpenImage("gradient:black-none");
|
||||
var verticalSpacing = Convert.ToInt32(height * 0.01111111111111111111111111111111);
|
||||
mwr.CurrentImage.CompositeImage(mwg, CompositeOperator.DstInCompositeOp, 0, verticalSpacing);
|
||||
|
||||
wandList.AddImage(mwr);
|
||||
int ex = (int)(wand.CurrentImage.Width - mwg.CurrentImage.Width) / 2;
|
||||
wand.CurrentImage.CompositeImage(wandList.AppendImages(true), CompositeOperator.AtopCompositeOp, ex, Convert.ToInt32(height * 0.26851851851851851851851851851852));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return wand;
|
||||
}
|
||||
}
|
||||
|
||||
private MagickWand BuildPosterCollageWand(IEnumerable<string> paths, int width, int height)
|
||||
{
|
||||
var inputPaths = ProjectPaths(paths, 4);
|
||||
using (var wandImages = new MagickWand(inputPaths))
|
||||
{
|
||||
var wand = new MagickWand(width, height);
|
||||
wand.OpenImage("gradient:#111111-#111111");
|
||||
using (var draw = new DrawingWand())
|
||||
{
|
||||
var iSlice = Convert.ToInt32(width * 0.225);
|
||||
int iTrans = Convert.ToInt32(height * .25);
|
||||
int iHeight = Convert.ToInt32(height * .65);
|
||||
var horizontalImagePadding = Convert.ToInt32(width * 0.0275);
|
||||
|
||||
foreach (var element in wandImages.ImageList)
|
||||
{
|
||||
using (var blackPixelWand = new PixelWand(ColorName.Black))
|
||||
{
|
||||
int iWidth = (int)Math.Abs(iHeight * element.Width / element.Height);
|
||||
element.Gravity = GravityType.CenterGravity;
|
||||
element.BackgroundColor = blackPixelWand;
|
||||
element.ResizeImage(iWidth, iHeight, FilterTypes.LanczosFilter);
|
||||
int ix = (int)Math.Abs((iWidth - iSlice) / 2);
|
||||
element.CropImage(iSlice, iHeight, ix, 0);
|
||||
|
||||
element.ExtentImage(iSlice, iHeight, 0 - horizontalImagePadding, 0);
|
||||
}
|
||||
}
|
||||
|
||||
wandImages.SetFirstIterator();
|
||||
using (var wandList = wandImages.AppendImages())
|
||||
{
|
||||
wandList.CurrentImage.TrimImage(1);
|
||||
using (var mwr = wandList.CloneMagickWand())
|
||||
{
|
||||
using (var blackPixelWand = new PixelWand(ColorName.Black))
|
||||
{
|
||||
using (var greyPixelWand = new PixelWand(ColorName.Grey70))
|
||||
{
|
||||
mwr.CurrentImage.ResizeImage(wandList.CurrentImage.Width, (wandList.CurrentImage.Height / 2), FilterTypes.LanczosFilter, 1);
|
||||
mwr.CurrentImage.FlipImage();
|
||||
|
||||
mwr.CurrentImage.AlphaChannel = AlphaChannelType.DeactivateAlphaChannel;
|
||||
mwr.CurrentImage.ColorizeImage(blackPixelWand, greyPixelWand);
|
||||
|
||||
using (var mwg = new MagickWand(wandList.CurrentImage.Width, iTrans))
|
||||
{
|
||||
mwg.OpenImage("gradient:black-none");
|
||||
var verticalSpacing = Convert.ToInt32(height * 0.01111111111111111111111111111111);
|
||||
mwr.CurrentImage.CompositeImage(mwg, CompositeOperator.CopyOpacityCompositeOp, 0, verticalSpacing);
|
||||
|
||||
wandList.AddImage(mwr);
|
||||
int ex = (int)(wand.CurrentImage.Width - mwg.CurrentImage.Width) / 2;
|
||||
wand.CurrentImage.CompositeImage(wandList.AppendImages(true), CompositeOperator.AtopCompositeOp, ex, Convert.ToInt32(height * .05));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return wand;
|
||||
}
|
||||
}
|
||||
|
||||
private MagickWand BuildPosterCollageWandWithText(IEnumerable<string> paths, string label, int width, int height)
|
||||
{
|
||||
var inputPaths = ProjectPaths(paths, 4);
|
||||
using (var wandImages = new MagickWand(inputPaths))
|
||||
{
|
||||
var wand = new MagickWand(width, height);
|
||||
wand.OpenImage("gradient:#111111-#111111");
|
||||
using (var draw = new DrawingWand())
|
||||
{
|
||||
using (var fcolor = new PixelWand(ColorName.White))
|
||||
{
|
||||
draw.FillColor = fcolor;
|
||||
draw.Font = MontserratLightFont;
|
||||
draw.FontSize = 60;
|
||||
draw.FontWeight = FontWeightType.LightStyle;
|
||||
draw.TextAntialias = true;
|
||||
}
|
||||
|
||||
var fontMetrics = wand.QueryFontMetrics(draw, label);
|
||||
var textContainerY = Convert.ToInt32(height * .165);
|
||||
wand.CurrentImage.AnnotateImage(draw, (width - fontMetrics.TextWidth) / 2, textContainerY, 0.0, label);
|
||||
|
||||
var iSlice = Convert.ToInt32(width * 0.225);
|
||||
int iTrans = Convert.ToInt32(height * 0.2);
|
||||
int iHeight = Convert.ToInt32(height * 0.46296296296296296296296296296296);
|
||||
var horizontalImagePadding = Convert.ToInt32(width * 0.0275);
|
||||
|
||||
foreach (var element in wandImages.ImageList)
|
||||
{
|
||||
int iWidth = (int)Math.Abs(iHeight * element.Width / element.Height);
|
||||
element.Gravity = GravityType.CenterGravity;
|
||||
element.BackgroundColor = new PixelWand("none", 1);
|
||||
element.ResizeImage(iWidth, iHeight, FilterTypes.LanczosFilter);
|
||||
int ix = (int)Math.Abs((iWidth - iSlice) / 2);
|
||||
element.CropImage(iSlice, iHeight, ix, 0);
|
||||
|
||||
element.ExtentImage(iSlice, iHeight, 0 - horizontalImagePadding, 0);
|
||||
}
|
||||
|
||||
wandImages.SetFirstIterator();
|
||||
using (var wandList = wandImages.AppendImages())
|
||||
{
|
||||
wandList.CurrentImage.TrimImage(1);
|
||||
using (var mwr = wandList.CloneMagickWand())
|
||||
{
|
||||
using (var blackPixelWand = new PixelWand(ColorName.Black))
|
||||
{
|
||||
using (var greyPixelWand = new PixelWand(ColorName.Grey70))
|
||||
{
|
||||
mwr.CurrentImage.ResizeImage(wandList.CurrentImage.Width, (wandList.CurrentImage.Height / 2), FilterTypes.LanczosFilter, 1);
|
||||
mwr.CurrentImage.FlipImage();
|
||||
|
||||
mwr.CurrentImage.AlphaChannel = AlphaChannelType.DeactivateAlphaChannel;
|
||||
mwr.CurrentImage.ColorizeImage(blackPixelWand, greyPixelWand);
|
||||
|
||||
using (var mwg = new MagickWand(wandList.CurrentImage.Width, iTrans))
|
||||
{
|
||||
mwg.OpenImage("gradient:black-none");
|
||||
var verticalSpacing = Convert.ToInt32(height * 0.01111111111111111111111111111111);
|
||||
mwr.CurrentImage.CompositeImage(mwg, CompositeOperator.DstInCompositeOp, 0, verticalSpacing);
|
||||
|
||||
wandList.AddImage(mwr);
|
||||
int ex = (int)(wand.CurrentImage.Width - mwg.CurrentImage.Width) / 2;
|
||||
wand.CurrentImage.CompositeImage(wandList.AppendImages(true), CompositeOperator.AtopCompositeOp, ex, Convert.ToInt32(height * 0.26851851851851851851851851851852));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return wand;
|
||||
}
|
||||
}
|
||||
|
||||
private MagickWand BuildThumbCollageWand(IEnumerable<string> paths, int width, int height)
|
||||
{
|
||||
var inputPaths = ProjectPaths(paths, 8);
|
||||
using (var wandImages = new MagickWand(inputPaths))
|
||||
{
|
||||
var wand = new MagickWand(width, height);
|
||||
wand.OpenImage("gradient:#111111-#111111");
|
||||
using (var draw = new DrawingWand())
|
||||
{
|
||||
var iSlice = Convert.ToInt32(width * .1166666667);
|
||||
int iTrans = Convert.ToInt32(height * .25);
|
||||
int iHeight = Convert.ToInt32(height * .62);
|
||||
var horizontalImagePadding = Convert.ToInt32(width * 0.0125);
|
||||
|
||||
foreach (var element in wandImages.ImageList)
|
||||
{
|
||||
using (var blackPixelWand = new PixelWand(ColorName.Black))
|
||||
{
|
||||
int iWidth = (int)Math.Abs(iHeight * element.Width / element.Height);
|
||||
element.Gravity = GravityType.CenterGravity;
|
||||
element.BackgroundColor = blackPixelWand;
|
||||
element.ResizeImage(iWidth, iHeight, FilterTypes.LanczosFilter);
|
||||
int ix = (int)Math.Abs((iWidth - iSlice) / 2);
|
||||
element.CropImage(iSlice, iHeight, ix, 0);
|
||||
|
||||
element.ExtentImage(iSlice, iHeight, 0 - horizontalImagePadding, 0);
|
||||
}
|
||||
}
|
||||
|
||||
wandImages.SetFirstIterator();
|
||||
using (var wandList = wandImages.AppendImages())
|
||||
{
|
||||
wandList.CurrentImage.TrimImage(1);
|
||||
using (var mwr = wandList.CloneMagickWand())
|
||||
{
|
||||
using (var blackPixelWand = new PixelWand(ColorName.Black))
|
||||
{
|
||||
using (var greyPixelWand = new PixelWand(ColorName.Grey70))
|
||||
{
|
||||
mwr.CurrentImage.ResizeImage(wandList.CurrentImage.Width, (wandList.CurrentImage.Height / 2), FilterTypes.LanczosFilter, 1);
|
||||
mwr.CurrentImage.FlipImage();
|
||||
|
||||
mwr.CurrentImage.AlphaChannel = AlphaChannelType.DeactivateAlphaChannel;
|
||||
mwr.CurrentImage.ColorizeImage(blackPixelWand, greyPixelWand);
|
||||
|
||||
using (var mwg = new MagickWand(wandList.CurrentImage.Width, iTrans))
|
||||
{
|
||||
mwg.OpenImage("gradient:black-none");
|
||||
var verticalSpacing = Convert.ToInt32(height * 0.01111111111111111111111111111111);
|
||||
mwr.CurrentImage.CompositeImage(mwg, CompositeOperator.CopyOpacityCompositeOp, 0, verticalSpacing);
|
||||
|
||||
wandList.AddImage(mwr);
|
||||
int ex = (int)(wand.CurrentImage.Width - mwg.CurrentImage.Width) / 2;
|
||||
wand.CurrentImage.CompositeImage(wandList.AppendImages(true), CompositeOperator.AtopCompositeOp, ex, Convert.ToInt32(height * .085));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return wand;
|
||||
}
|
||||
}
|
||||
|
||||
private MagickWand BuildSquareCollageWand(IEnumerable<string> paths, int width, int height)
|
||||
{
|
||||
var inputPaths = ProjectPaths(paths, 4);
|
||||
using (var wandImages = new MagickWand(inputPaths))
|
||||
{
|
||||
var wand = new MagickWand(width, height);
|
||||
wand.OpenImage("gradient:#111111-#111111");
|
||||
using (var draw = new DrawingWand())
|
||||
{
|
||||
var iSlice = Convert.ToInt32(width * .225);
|
||||
int iTrans = Convert.ToInt32(height * .25);
|
||||
int iHeight = Convert.ToInt32(height * .63);
|
||||
var horizontalImagePadding = Convert.ToInt32(width * 0.02);
|
||||
|
||||
foreach (var element in wandImages.ImageList)
|
||||
{
|
||||
using (var blackPixelWand = new PixelWand(ColorName.Black))
|
||||
{
|
||||
int iWidth = (int)Math.Abs(iHeight * element.Width / element.Height);
|
||||
element.Gravity = GravityType.CenterGravity;
|
||||
element.BackgroundColor = blackPixelWand;
|
||||
element.ResizeImage(iWidth, iHeight, FilterTypes.LanczosFilter);
|
||||
int ix = (int)Math.Abs((iWidth - iSlice) / 2);
|
||||
element.CropImage(iSlice, iHeight, ix, 0);
|
||||
|
||||
element.ExtentImage(iSlice, iHeight, 0 - horizontalImagePadding, 0);
|
||||
}
|
||||
}
|
||||
|
||||
wandImages.SetFirstIterator();
|
||||
using (var wandList = wandImages.AppendImages())
|
||||
{
|
||||
wandList.CurrentImage.TrimImage(1);
|
||||
using (var mwr = wandList.CloneMagickWand())
|
||||
{
|
||||
using (var blackPixelWand = new PixelWand(ColorName.Black))
|
||||
{
|
||||
using (var greyPixelWand = new PixelWand(ColorName.Grey70))
|
||||
{
|
||||
mwr.CurrentImage.ResizeImage(wandList.CurrentImage.Width, (wandList.CurrentImage.Height / 2), FilterTypes.LanczosFilter, 1);
|
||||
mwr.CurrentImage.FlipImage();
|
||||
|
||||
mwr.CurrentImage.AlphaChannel = AlphaChannelType.DeactivateAlphaChannel;
|
||||
mwr.CurrentImage.ColorizeImage(blackPixelWand, greyPixelWand);
|
||||
|
||||
using (var mwg = new MagickWand(wandList.CurrentImage.Width, iTrans))
|
||||
{
|
||||
mwg.OpenImage("gradient:black-none");
|
||||
var verticalSpacing = Convert.ToInt32(height * 0.01111111111111111111111111111111);
|
||||
mwr.CurrentImage.CompositeImage(mwg, CompositeOperator.CopyOpacityCompositeOp, 0, verticalSpacing);
|
||||
|
||||
wandList.AddImage(mwr);
|
||||
int ex = (int)(wand.CurrentImage.Width - mwg.CurrentImage.Width) / 2;
|
||||
wand.CurrentImage.CompositeImage(wandList.AppendImages(true), CompositeOperator.AtopCompositeOp, ex, Convert.ToInt32(height * .07));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return wand;
|
||||
}
|
||||
}
|
||||
|
||||
private MagickWand BuildSquareCollageWandWithText(IEnumerable<string> paths, string label, int width, int height)
|
||||
{
|
||||
var inputPaths = ProjectPaths(paths, 4);
|
||||
using (var wandImages = new MagickWand(inputPaths))
|
||||
{
|
||||
var wand = new MagickWand(width, height);
|
||||
wand.OpenImage("gradient:#111111-#111111");
|
||||
using (var draw = new DrawingWand())
|
||||
{
|
||||
using (var fcolor = new PixelWand(ColorName.White))
|
||||
{
|
||||
draw.FillColor = fcolor;
|
||||
draw.Font = MontserratLightFont;
|
||||
draw.FontSize = 60;
|
||||
draw.FontWeight = FontWeightType.LightStyle;
|
||||
draw.TextAntialias = true;
|
||||
}
|
||||
|
||||
var fontMetrics = wand.QueryFontMetrics(draw, label);
|
||||
var textContainerY = Convert.ToInt32(height * .165);
|
||||
wand.CurrentImage.AnnotateImage(draw, (width - fontMetrics.TextWidth) / 2, textContainerY, 0.0, label);
|
||||
|
||||
var iSlice = Convert.ToInt32(width * .225);
|
||||
int iTrans = Convert.ToInt32(height * 0.2);
|
||||
int iHeight = Convert.ToInt32(height * 0.46296296296296296296296296296296);
|
||||
var horizontalImagePadding = Convert.ToInt32(width * 0.02);
|
||||
|
||||
foreach (var element in wandImages.ImageList)
|
||||
{
|
||||
int iWidth = (int)Math.Abs(iHeight * element.Width / element.Height);
|
||||
element.Gravity = GravityType.CenterGravity;
|
||||
element.BackgroundColor = new PixelWand("none", 1);
|
||||
element.ResizeImage(iWidth, iHeight, FilterTypes.LanczosFilter);
|
||||
int ix = (int)Math.Abs((iWidth - iSlice) / 2);
|
||||
element.CropImage(iSlice, iHeight, ix, 0);
|
||||
|
||||
element.ExtentImage(iSlice, iHeight, 0 - horizontalImagePadding, 0);
|
||||
}
|
||||
|
||||
wandImages.SetFirstIterator();
|
||||
using (var wandList = wandImages.AppendImages())
|
||||
{
|
||||
wandList.CurrentImage.TrimImage(1);
|
||||
using (var mwr = wandList.CloneMagickWand())
|
||||
{
|
||||
using (var blackPixelWand = new PixelWand(ColorName.Black))
|
||||
{
|
||||
using (var greyPixelWand = new PixelWand(ColorName.Grey70))
|
||||
{
|
||||
mwr.CurrentImage.ResizeImage(wandList.CurrentImage.Width, (wandList.CurrentImage.Height / 2), FilterTypes.LanczosFilter, 1);
|
||||
mwr.CurrentImage.FlipImage();
|
||||
|
||||
mwr.CurrentImage.AlphaChannel = AlphaChannelType.DeactivateAlphaChannel;
|
||||
mwr.CurrentImage.ColorizeImage(blackPixelWand, greyPixelWand);
|
||||
|
||||
using (var mwg = new MagickWand(wandList.CurrentImage.Width, iTrans))
|
||||
{
|
||||
mwg.OpenImage("gradient:black-none");
|
||||
var verticalSpacing = Convert.ToInt32(height * 0.01111111111111111111111111111111);
|
||||
mwr.CurrentImage.CompositeImage(mwg, CompositeOperator.DstInCompositeOp, 0, verticalSpacing);
|
||||
|
||||
wandList.AddImage(mwr);
|
||||
int ex = (int)(wand.CurrentImage.Width - mwg.CurrentImage.Width) / 2;
|
||||
wand.CurrentImage.CompositeImage(wandList.AppendImages(true), CompositeOperator.AtopCompositeOp, ex, Convert.ToInt32(height * 0.26851851851851851851851851851852));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return wand;
|
||||
}
|
||||
}
|
||||
|
||||
private string MontserratLightFont
|
||||
{
|
||||
get { return PlayedIndicatorDrawer.ExtractFont("MontserratLight.otf", _appPaths); }
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user