Created
September 13, 2019 13:42
-
-
Save johnathaningle/48437a1cd0b3c06d21c9b6a4ff8d29c6 to your computer and use it in GitHub Desktop.
Get the pixels from a jpeg with ImageSharp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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