How can I retrieve a JPEG image codec in F#?
In C#, I can retrieve a JPEG encoder like this:
var jpegEncoder =
ImageCodecInfo.GetImageEncoders()
.Where(e => e.FormatID == ImageFormat.Jpeg.Guid)
.Single();
I'd like to do the same in thing F# and I know there's a beautifully succinct way to do it, but开发者_开发百科 I'm just starting out and I can't quite figure it out. I see there's a Where method available hanging off of GetImageEncoders()
but I can't figure out what to pass into it. I read Don Syme's blog post on F# and LINQ, but I just don't have enough experience in F# to really understand it.
Is there a nice way I can do this same thing in F#?
#r "System.Drawing"
open System.Drawing.Imaging
let jpeg =
System.Drawing.Imaging.ImageCodecInfo.GetImageEncoders()
|> Seq.find (fun e -> e.FormatID = ImageFormat.Jpeg.Guid)
精彩评论