1

I am trying to convert raw image file to .jpeg using below code:

byte[] bytes = System.IO.File.ReadAllBytes(@"C:\TestFiles\input.NEF");
using (Image image = Image.FromStream(new MemoryStream(bytes)))
{
    image.Save(@"C:\TestFiles\output.jpeg", ImageFormat.Jpeg);
}

But fails with the message:

Parameter is not valid.

I know it may be because low memory (from this question about C# “Parameter is not valid.” creating new bitmap) but I believe there is enough memory. The input .nef file is 11.1mb

enter image description here

Community
  • 1
  • 1
huMpty duMpty
  • 14,346
  • 14
  • 60
  • 99
  • 4
    `.NEF` files are not supported by .NET framework - download the SDK from Nikon – fubo Feb 09 '16 at 09:47
  • As @fubo has told you, you'll need a external library to open .Nef files, something like this http://sourceforge.net/p/nikoncswrapper/wiki/Home/ – Pikoh Feb 09 '16 at 09:50
  • 1
    Image.FromStream does not know what a .NEF is... try convert it locally to a known format... PNG or BMP then try the same code. if it works it means that it didnt understand .NEF. and as other have said you will need to use a lib that understands .NEF – Seabizkit Feb 09 '16 at 09:52

0 Answers0