This question has already been answered:
This code snatches the image on the bottom. Save to a file with the same name does not give due to an error using the file. Therefore, I created a temporary file with the tmp extension. The problem occurs when deleting - due to the fact that the resource fileName is busy. How to release him correctly?
byte[] photoBytes = File.ReadAllBytes(fileName); // для чтения FileStream fs = File.OpenWrite(fileName+".tmp"); // для записи using (MemoryStream inStream = new MemoryStream(photoBytes)) { using (MemoryStream outStream = new MemoryStream()) { using (ImageFactory imageFactory = new ImageFactory(preserveExifData: true)) { Image tmp = new Bitmap(Image.FromFile(fileName)); imageFactory.Load(inStream) // грузим картинку .Crop(new Rectangle(0, 0, tmp.Width, tmp.Height - 62)) .Save(outStream); // сохраняем в поток outStream.WriteTo(fs); // записываем в файл outStream.Close(); // не забываем закрывать потоки ввода-вывода } inStream.Close(); // не забываем закрывать потоки ввода-вывода fs.Close(); } } File.Delete(fileName); File.Move(fileName+".tmp", fileName);