# The right way to save image to external SD card

**URL:** <https://forums.openmv.io/t/the-right-way-to-save-image-to-external-sd-card/5742>\
**Category:** OpenMV Boards\
**Created:** [April 20, 2021, 11:02am UTC](https://forums.openmv.io/t/the-right-way-to-save-image-to-external-sd-card/5742 "2021-04-20T11:02:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![vip](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/vip/32/1521_2.png) [@vip](https://forums.openmv.io/u/vip)\
**Post date:** [April 20, 2021, 11:02am UTC](https://forums.openmv.io/t/the-right-way-to-save-image-to-external-sd-card/5742/1 "2021-04-20T11:02:38Z")

</div>

Hi,

I am writing a program to capture object by OpenMV camera. After the object is detected, I use `image.save()` to save image into external SD card. After I remount the OpenMV storage, I found the image is corrupted (refer to the attached file).

I wonder what the right approach to save the image file is. I.e. what should I do after executing the `.save()` method?

I also tried to add `time.sleep(1)` for the buffer flushing but it didn’t work.

Thanks.

![864918050725124-210420-185657-388858](https://canada1.discourse-cdn.com/flex029/uploads/openmv1/original/2X/8/8d7e03523da44124c96d48e4dbdfff58a47beb1c.jpeg)

---

<div class="post-metadata">

**Author:** ![vip](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/vip/32/1521_2.png) [@vip](https://forums.openmv.io/u/vip)\
**Post date:** [April 20, 2021, 11:33am UTC](https://forums.openmv.io/t/the-right-way-to-save-image-to-external-sd-card/5742/2 "2021-04-20T11:33:16Z")

</div>

I checked my code carefully and finally found the reason!

It is incorrectly use `sensor.dealloc_extra_fb()` to deallocate the memory before saving the image to file, which caused some memory are overwritten but still being saved to file.

It is not the file corrupted but the content is.
