You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using ImageResizer;
|
|
|
|
|
using NzbDrone.Common.Disk;
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.MediaCover
|
|
|
|
|
{
|
|
|
|
|
public interface IImageResizer
|
|
|
|
|
{
|
|
|
|
|
void Resize(string source, string destination, int height);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class ImageResizer : IImageResizer
|
|
|
|
|
{
|
|
|
|
|
private readonly IDiskProvider _diskProvider;
|
|
|
|
|
|
|
|
|
|
public ImageResizer(IDiskProvider diskProvider)
|
|
|
|
|
{
|
|
|
|
|
_diskProvider = diskProvider;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Resize(string source, string destination, int height)
|
|
|
|
|
{
|
|
|
|
|
using (var sourceStream = _diskProvider.OpenReadStream(source))
|
|
|
|
|
{
|
|
|
|
|
using (var outputStream = _diskProvider.OpenWriteStream(destination))
|
|
|
|
|
{
|
|
|
|
|
var settings = new Instructions();
|
|
|
|
|
settings.Height = height;
|
|
|
|
|
|
|
|
|
|
var job = new ImageJob(sourceStream, outputStream, settings);
|
|
|
|
|
|
|
|
|
|
ImageBuilder.Current.Build(job);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|