aboutsummaryrefslogtreecommitdiff
path: root/Emby.Drawing
diff options
context:
space:
mode:
Diffstat (limited to 'Emby.Drawing')
-rw-r--r--Emby.Drawing/Emby.Drawing.csproj4
-rw-r--r--Emby.Drawing/GDI/GDIImageEncoder.cs28
-rw-r--r--Emby.Drawing/GDI/empty.pngbin0 -> 158 bytes
-rw-r--r--Emby.Drawing/IImageEncoder.cs18
-rw-r--r--Emby.Drawing/ImageMagick/ImageMagickEncoder.cs19
-rw-r--r--Emby.Drawing/ImageMagick/StripCollageBuilder.cs4
-rw-r--r--Emby.Drawing/ImageProcessor.cs21
-rw-r--r--Emby.Drawing/NullImageEncoder.cs64
8 files changed, 141 insertions, 17 deletions
diff --git a/Emby.Drawing/Emby.Drawing.csproj b/Emby.Drawing/Emby.Drawing.csproj
index e8a09b2ae..e9911a12d 100644
--- a/Emby.Drawing/Emby.Drawing.csproj
+++ b/Emby.Drawing/Emby.Drawing.csproj
@@ -75,6 +75,7 @@
<Compile Include="ImageProcessor.cs" />
<Compile Include="ImageMagick\PercentPlayedDrawer.cs" />
<Compile Include="ImageMagick\PlayedIndicatorDrawer.cs" />
+ <Compile Include="NullImageEncoder.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ImageMagick\UnplayedCountIndicator.cs" />
</ItemGroup>
@@ -99,6 +100,9 @@
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
+ <ItemGroup>
+ <EmbeddedResource Include="GDI\empty.png" />
+ </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
diff --git a/Emby.Drawing/GDI/GDIImageEncoder.cs b/Emby.Drawing/GDI/GDIImageEncoder.cs
index 6d0998662..530613741 100644
--- a/Emby.Drawing/GDI/GDIImageEncoder.cs
+++ b/Emby.Drawing/GDI/GDIImageEncoder.cs
@@ -1,5 +1,4 @@
-using MediaBrowser.Common.IO;
-using MediaBrowser.Controller.Drawing;
+using MediaBrowser.Controller.Drawing;
using MediaBrowser.Model.Drawing;
using MediaBrowser.Model.Logging;
using System;
@@ -23,7 +22,20 @@ namespace Emby.Drawing.GDI
_fileSystem = fileSystem;
_logger = logger;
- _logger.Info("GDI image processor initialized");
+ LogInfo();
+ }
+
+ private void LogInfo()
+ {
+ _logger.Info("GDIImageEncoder starting");
+ using (var stream = GetType().Assembly.GetManifestResourceStream(GetType().Namespace + ".empty.png"))
+ {
+ using (var img = Image.FromStream(stream))
+ {
+
+ }
+ }
+ _logger.Info("GDIImageEncoder started");
}
public string[] SupportedInputFormats
@@ -253,5 +265,15 @@ namespace Emby.Drawing.GDI
{
get { return "GDI"; }
}
+
+ public bool SupportsImageCollageCreation
+ {
+ get { return true; }
+ }
+
+ public bool SupportsImageEncoding
+ {
+ get { return true; }
+ }
}
}
diff --git a/Emby.Drawing/GDI/empty.png b/Emby.Drawing/GDI/empty.png
new file mode 100644
index 000000000..42e2b375e
--- /dev/null
+++ b/Emby.Drawing/GDI/empty.png
Binary files differ
diff --git a/Emby.Drawing/IImageEncoder.cs b/Emby.Drawing/IImageEncoder.cs
index 29261dbdb..4469075a6 100644
--- a/Emby.Drawing/IImageEncoder.cs
+++ b/Emby.Drawing/IImageEncoder.cs
@@ -17,12 +17,6 @@ namespace Emby.Drawing
/// <value>The supported output formats.</value>
ImageFormat[] SupportedOutputFormats { get; }
/// <summary>
- /// Gets the size of the image.
- /// </summary>
- /// <param name="path">The path.</param>
- /// <returns>ImageSize.</returns>
- ImageSize GetImageSize(string path);
- /// <summary>
/// Crops the white space.
/// </summary>
/// <param name="inputPath">The input path.</param>
@@ -49,5 +43,17 @@ namespace Emby.Drawing
/// </summary>
/// <value>The name.</value>
string Name { get; }
+
+ /// <summary>
+ /// Gets a value indicating whether [supports image collage creation].
+ /// </summary>
+ /// <value><c>true</c> if [supports image collage creation]; otherwise, <c>false</c>.</value>
+ bool SupportsImageCollageCreation { get; }
+
+ /// <summary>
+ /// Gets a value indicating whether [supports image encoding].
+ /// </summary>
+ /// <value><c>true</c> if [supports image encoding]; otherwise, <c>false</c>.</value>
+ bool SupportsImageEncoding { get; }
}
}
diff --git a/Emby.Drawing/ImageMagick/ImageMagickEncoder.cs b/Emby.Drawing/ImageMagick/ImageMagickEncoder.cs
index e73184974..ed0760ee3 100644
--- a/Emby.Drawing/ImageMagick/ImageMagickEncoder.cs
+++ b/Emby.Drawing/ImageMagick/ImageMagickEncoder.cs
@@ -9,7 +9,6 @@ using System;
using System.IO;
using System.Linq;
using CommonIO;
-using MediaBrowser.Common.IO;
namespace Emby.Drawing.ImageMagick
{
@@ -27,7 +26,7 @@ namespace Emby.Drawing.ImageMagick
_httpClient = httpClient;
_fileSystem = fileSystem;
- LogImageMagickVersion();
+ LogVersion();
}
public string[] SupportedInputFormats
@@ -68,7 +67,7 @@ namespace Emby.Drawing.ImageMagick
}
}
- private void LogImageMagickVersion()
+ private void LogVersion()
{
_logger.Info("ImageMagick version: " + Wand.VersionString);
TestWebp();
@@ -88,9 +87,9 @@ namespace Emby.Drawing.ImageMagick
wand.SaveImage(tmpPath);
}
}
- catch (Exception ex)
+ catch
{
- _logger.ErrorException("Error loading webp: ", ex);
+ //_logger.ErrorException("Error loading webp: ", ex);
_webpAvailable = false;
}
}
@@ -255,5 +254,15 @@ namespace Emby.Drawing.ImageMagick
throw new ObjectDisposedException(GetType().Name);
}
}
+
+ public bool SupportsImageCollageCreation
+ {
+ get { return true; }
+ }
+
+ public bool SupportsImageEncoding
+ {
+ get { return true; }
+ }
}
}
diff --git a/Emby.Drawing/ImageMagick/StripCollageBuilder.cs b/Emby.Drawing/ImageMagick/StripCollageBuilder.cs
index e8161c179..a7e3a155d 100644
--- a/Emby.Drawing/ImageMagick/StripCollageBuilder.cs
+++ b/Emby.Drawing/ImageMagick/StripCollageBuilder.cs
@@ -354,14 +354,14 @@ namespace Emby.Drawing.ImageMagick
private MagickWand BuildSquareCollageWand(List<string> paths, int width, int height)
{
- var inputPaths = ImageHelpers.ProjectPaths(paths, 4);
+ var inputPaths = ImageHelpers.ProjectPaths(paths, 3);
using (var wandImages = new MagickWand(inputPaths.ToArray()))
{
var wand = new MagickWand(width, height);
wand.OpenImage("gradient:#111111-#111111");
using (var draw = new DrawingWand())
{
- var iSlice = Convert.ToInt32(width * .225);
+ var iSlice = Convert.ToInt32(width * .3);
int iTrans = Convert.ToInt32(height * .25);
int iHeight = Convert.ToInt32(height * .63);
var horizontalImagePadding = Convert.ToInt32(width * 0.02);
diff --git a/Emby.Drawing/ImageProcessor.cs b/Emby.Drawing/ImageProcessor.cs
index 05c156e6a..9d7d1dbe9 100644
--- a/Emby.Drawing/ImageProcessor.cs
+++ b/Emby.Drawing/ImageProcessor.cs
@@ -110,6 +110,15 @@ namespace Emby.Drawing
}
}
+
+ public bool SupportsImageCollageCreation
+ {
+ get
+ {
+ return _imageEncoder.SupportsImageCollageCreation;
+ }
+ }
+
private string ResizedImageCachePath
{
get
@@ -170,6 +179,11 @@ namespace Emby.Drawing
var originalImagePath = originalImage.Path;
+ if (!_imageEncoder.SupportsImageEncoding)
+ {
+ return originalImagePath;
+ }
+
if (options.HasDefaultOptions(originalImagePath) && options.Enhancers.Count == 0 && !options.CropWhiteSpace)
{
// Just spit out the original file if all the options are default
@@ -178,7 +192,7 @@ namespace Emby.Drawing
var dateModified = originalImage.DateModified;
- if (options.CropWhiteSpace)
+ if (options.CropWhiteSpace && _imageEncoder.SupportsImageEncoding)
{
var tuple = await GetWhitespaceCroppedImage(originalImagePath, dateModified).ConfigureAwait(false);
@@ -295,6 +309,11 @@ namespace Emby.Drawing
_imageEncoder.CropWhiteSpace(originalImagePath, croppedImagePath);
}
+ catch (NotImplementedException)
+ {
+ // No need to spam the log with an error message
+ return new Tuple<string, DateTime>(originalImagePath, dateModified);
+ }
catch (Exception ex)
{
// We have to have a catch-all here because some of the .net image methods throw a plain old Exception
diff --git a/Emby.Drawing/NullImageEncoder.cs b/Emby.Drawing/NullImageEncoder.cs
new file mode 100644
index 000000000..30ea36329
--- /dev/null
+++ b/Emby.Drawing/NullImageEncoder.cs
@@ -0,0 +1,64 @@
+using System;
+using MediaBrowser.Controller.Drawing;
+using MediaBrowser.Model.Drawing;
+
+namespace Emby.Drawing
+{
+ public class NullImageEncoder : IImageEncoder
+ {
+ public string[] SupportedInputFormats
+ {
+ get
+ {
+ return new[]
+ {
+ "png",
+ "jpeg",
+ "jpg"
+ };
+ }
+ }
+
+ public ImageFormat[] SupportedOutputFormats
+ {
+ get
+ {
+ return new[] { ImageFormat.Jpg, ImageFormat.Png };
+ }
+ }
+
+ public void CropWhiteSpace(string inputPath, string outputPath)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void EncodeImage(string inputPath, string outputPath, int width, int height, int quality, ImageProcessingOptions options)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void CreateImageCollage(ImageCollageOptions options)
+ {
+ throw new NotImplementedException();
+ }
+
+ public string Name
+ {
+ get { return "Null Image Encoder"; }
+ }
+
+ public bool SupportsImageCollageCreation
+ {
+ get { return false; }
+ }
+
+ public bool SupportsImageEncoding
+ {
+ get { return false; }
+ }
+
+ public void Dispose()
+ {
+ }
+ }
+}