Browse Source

Testing huge image

Former-commit-id: 6a06733cf9d08aadf02c9672acadbfefad0454b6
Former-commit-id: 429a19b33aa0dbd5f75482841781422ff31f972e
af/merge-core
James South 12 years ago
parent
commit
d0b9fe94fb
  1. 125
      src/ImageProcessor.Playground/Program.cs
  2. 1
      src/ImageProcessor.Playground/images/input/test5.jpg.REMOVED.git-id

125
src/ImageProcessor.Playground/Program.cs

@ -30,8 +30,6 @@ namespace ImageProcessor.PlayGround
/// </summary> /// </summary>
public class Program public class Program
{ {
protected static readonly IEnumerable<ISupportedImageFormat> formats = ImageProcessorBootstrapper.Instance.SupportedImageFormats;
/// <summary> /// <summary>
/// The main routine. /// The main routine.
/// </summary> /// </summary>
@ -50,75 +48,78 @@ namespace ImageProcessor.PlayGround
di.Create(); di.Create();
} }
Image mask = Image.FromFile(Path.Combine(resolvedPath, "mask.png")); // Image mask = Image.FromFile(Path.Combine(resolvedPath, "mask.png"));
Image overlay = Image.FromFile(Path.Combine(resolvedPath, "imageprocessor.128.png")); // Image overlay = Image.FromFile(Path.Combine(resolvedPath, "imageprocessor.128.png"));
//FileInfo fileInfo = new FileInfo(Path.Combine(resolvedPath, "monster.png")); FileInfo fileInfo = new FileInfo(Path.Combine(resolvedPath, "test5.jpg"));
IEnumerable<FileInfo> files = GetFilesByExtensions(di, ".gif"); IEnumerable<FileInfo> files = GetFilesByExtensions(di, ".gif");
//IEnumerable<FileInfo> files = GetFilesByExtensions(di, ".gif", ".webp", ".bmp", ".jpg", ".png", ".tif"); //IEnumerable<FileInfo> files = GetFilesByExtensions(di, ".gif", ".webp", ".bmp", ".jpg", ".png", ".tif");
foreach (FileInfo fileInfo in files) // foreach (FileInfo fileInfo in files)
{ // {
byte[] photoBytes = File.ReadAllBytes(fileInfo.FullName); byte[] photoBytes = File.ReadAllBytes(fileInfo.FullName);
Console.WriteLine("Processing: " + fileInfo.Name); Console.WriteLine("Processing: " + fileInfo.Name);
Stopwatch stopwatch = new Stopwatch(); Stopwatch stopwatch = new Stopwatch();
stopwatch.Start(); stopwatch.Start();
// ImageProcessor // ImageProcessor
using (MemoryStream inStream = new MemoryStream(photoBytes)) using (MemoryStream inStream = new MemoryStream(photoBytes))
{
using (ImageFactory imageFactory = new ImageFactory(true))
{ {
using (ImageFactory imageFactory = new ImageFactory(true)) Size size = new Size(844, 1017);
{ ResizeLayer layer = new ResizeLayer(size, ResizeMode.Max, AnchorPosition.Center, false);
Size size = new Size(844, 1017);
ResizeLayer layer = new ResizeLayer(size, ResizeMode.Max, AnchorPosition.Center, false); //ContentAwareResizeLayer layer = new ContentAwareResizeLayer(size)
//{
//ContentAwareResizeLayer layer = new ContentAwareResizeLayer(size) // ConvolutionType = ConvolutionType.Sobel
//{ //};
// ConvolutionType = ConvolutionType.Sobel // Load, resize, set the format and quality and save an image.
//}; imageFactory.Load(inStream)
// Load, resize, set the format and quality and save an image. //.Overlay(new ImageLayer
imageFactory.Load(inStream) // {
//.Overlay(new ImageLayer // Image = overlay,
// { // Opacity = 50
// Image = overlay, // })
// Opacity = 50 //.Alpha(50)
// }) //.BackgroundColor(Color.White)
//.Alpha(50) //.Resize(new Size((int)(size.Width * 1.1), 0))
//.BackgroundColor(Color.White) //.ContentAwareResize(layer)
//.Resize(new Size((int)(size.Width * 1.1), 0)) //.Constrain(size)
//.ContentAwareResize(layer) //.Mask(mask)
//.Constrain(size) //.Format(new PngFormat())
//.Mask(mask) //.BackgroundColor(Color.Cyan)
//.Format(new PngFormat()) //.ReplaceColor(Color.FromArgb(255, 223, 224), Color.FromArgb(121, 188, 255), 128)
//.BackgroundColor(Color.Cyan) //.Resize(size)
//.ReplaceColor(Color.FromArgb(255, 223, 224), Color.FromArgb(121, 188, 255), 128) .Resize(new ResizeLayer(size, ResizeMode.Max))
//.Resize(size) // .Resize(new ResizeLayer(size, ResizeMode.Stretch))
// .Resize(new ResizeLayer(size, ResizeMode.Max)) //.DetectEdges(new SobelEdgeFilter(), true)
// .Resize(new ResizeLayer(size, ResizeMode.Stretch)) //.DetectEdges(new LaplacianOfGaussianEdgeFilter())
//.DetectEdges(new SobelEdgeFilter(), true) //.EntropyCrop()
//.DetectEdges(new LaplacianOfGaussianEdgeFilter()) //.Filter(MatrixFilters.Invert)
//.EntropyCrop() //.Contrast(50)
//.Filter(MatrixFilters.Invert) //.Filter(MatrixFilters.Comic)
//.Contrast(50) //.Flip()
//.Filter(MatrixFilters.Comic) //.Filter(MatrixFilters.HiSatch)
//.Flip() //.Pixelate(8)
//.Filter(MatrixFilters.HiSatch) //.Rotate(45)
.Pixelate(8) //.GaussianSharpen(10)
.Rotate(45) //.Format(new PngFormat() { IsIndexed = true })
//.GaussianSharpen(10) //.Format(new PngFormat() { IsIndexed = true })
//.Format(new PngFormat() { IsIndexed = true }) //.Save(Path.GetFullPath(Path.Combine(Path.GetDirectoryName(path), @"..\..\images\output", fileInfo.Name)));
//.Format(new PngFormat() { IsIndexed = true }) .Save(Path.GetFullPath(Path.Combine(Path.GetDirectoryName(path), @"..\..\images\output", Path.GetFileNameWithoutExtension(fileInfo.Name) + ".png")));
//.Save(Path.GetFullPath(Path.Combine(Path.GetDirectoryName(path), @"..\..\images\output", fileInfo.Name)));
.Save(Path.GetFullPath(Path.Combine(Path.GetDirectoryName(path), @"..\..\images\output", Path.GetFileNameWithoutExtension(fileInfo.Name) + ".png"))); stopwatch.Stop();
stopwatch.Stop();
}
} }
}
Console.WriteLine(@"Completed {0} in {1:s\.fff} secs with peak memory usage of {2}.", fileInfo.Name, stopwatch.Elapsed, Process.GetCurrentProcess().PeakWorkingSet64.ToString("#,#")); long peakWorkingSet64 = Process.GetCurrentProcess().PeakWorkingSet64;
float mB = peakWorkingSet64 / (float)1024 / 1024;
//Console.WriteLine("Processed: " + fileInfo.Name + " in " + stopwatch.ElapsedMilliseconds + "ms"); Console.WriteLine(@"Completed {0} in {1:s\.fff} secs {2}Peak memory usage was {3} bytes or {4} Mb.", fileInfo.Name, stopwatch.Elapsed, Environment.NewLine, peakWorkingSet64.ToString("#,#"), mB);
}
//Console.WriteLine("Processed: " + fileInfo.Name + " in " + stopwatch.ElapsedMilliseconds + "ms");
//}
Console.ReadLine(); Console.ReadLine();
} }

1
src/ImageProcessor.Playground/images/input/test5.jpg.REMOVED.git-id

@ -0,0 +1 @@
04f8079eef57529bd63ff1e8227703acbb45aa15
Loading…
Cancel
Save