Catalog/CatalogLib/ImgSharpCreator.cs
2017-03-17 16:23:29 +01:00

83 lines
2.6 KiB
C#

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ImageSharp;
namespace CatalogLib
{
public class ImgSharpCreator : IImageProcessor
{
public void Start(FileInfo workFile)
{
using (Image image = new Image(workFile.FullName))
{
if (PicSettings.Instance.UsaRotazioneAutomatica)
{
var exif = image.MetaData.ExifProfile;
if (exif != null)
{
var o = exif.GetValue(ExifTag.Orientation);
if (o != null)
{
int v = (int)o.Value;
switch (v)
{
//1 = Horizontal(normal)
//2 = Mirror horizontal
//3 = Rotate 180
//4 = Mirror vertical
//5 = Mirror horizontal and rotate 270 CW
//6 = Rotate 90 CW
//7 = Mirror horizontal and rotate 90 CW
//8 = Rotate 270 CW
case 1:
break;
case 2:
break;
case 3:
//image.Rotate(180f);
//image.Rotate(90);
image.Rotate(180f);
break;
case 4:
break;
case 5:
break;
case 6:
image.Rotate(90);
break;
case 7:
break;
case 8:
image.Rotate(-90);
break;
}
}
}
}
//JpegDecoder j = new JpegDecoder();
image.Save(Path.Combine(PicSettings.Instance.DirectoryDestinazione, workFile.Name));
//image.Resize(200, 200).Save("");
}
}
private void SetExtraText(ref Image image)
{
//if ()
}
}
}