Skip to content

Instantly share code, notes, and snippets.

@johnathaningle
Created September 13, 2019 13:42
Show Gist options
  • Save johnathaningle/48437a1cd0b3c06d21c9b6a4ff8d29c6 to your computer and use it in GitHub Desktop.
Save johnathaningle/48437a1cd0b3c06d21c9b6a4ff8d29c6 to your computer and use it in GitHub Desktop.
Get the pixels from a jpeg with ImageSharp
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Formats.Jpeg;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
using System;
using System.IO;
namespace ImageSharpConsole
{
class Program
{
static void Main(string[] args)
{
try
{
System.IO.Directory.CreateDirectory("output");
}
catch
{
Console.WriteLine("Output directory could not be created");
}
using(Image image = Image.Load(@"C:\Users\john.ingle\source\repos\ProcessingWebApp\ImageSharpConsole\foxlogo.jpg"))
{
image.Clone(x => x.Pixelate(32))
.Save("output/test.jpg");
for(int i = 0; i < image.Height; i++)
{
for(int j = 0; j < image.Width; j++)
{
var pixel = image.GetPixel(i, j);
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment