// I learned how to use ImageSharp by reading its // documentation and sample code. open SixLabors.ImageSharp open SixLabors.ImageSharp.Processing [] let main args = // make sure the user gave us an image file as input if args.Length <> 1 then printfn "Usage: dotnet run " exit 1 // "use" just means "declare a variable on which we call // "close" when it goes out of scope; // Image.Load returns a "Closeable" object. use image = Image.Load args[0] // ImageSharp's Mutate method takes a function that changes // the image through side effects (yuck!) image.Mutate (fun x -> x.Resize(image.Width / 2, image.Height / 2).Grayscale().Rotate(45f) |> ignore) // We have to explicitly ask the image to save itself. // Here we are computing a filename based off of the original // one but with "-mutated.jpg" added on to the end. image.Save (sprintf "%s-mutated.jpg" args[0]) 0