cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possible to add metadata info to a .jpg using FatFS?

DCajigal
Associate III

Hi,

For one project i have to save some pictures taken with one SPI Camera into an SD Card by SPI and i have to save also some info related to the image. For saving the pictures i am going to use FATFS and i was wondering if i could save some Exif info along with the picture. Otherwise i would have to create another file on the SD and link it to the picture. Thanks in advance.

10 REPLIES 10
Ozone
Lead II

EXIF metadata are part of the image file, and independant of the filesystem.

The FatFS filesystem does not care about the content of a file.

DCajigal
Associate III

I understand...but i have been searching for some library to do this and i dont find anything. I have found libraries but for Unix systems only. Would you know if there is an easy way to do this in a STM32F4 and .jpg images? I would have also the option of working with raw images, but i would prefer to use the JPG for space saving. Thank you!

I don't work on graphic applications with Cortex M, mainly for that reason.

For private projects, I rather pull a Linux board for about the same price, with most of those libs directly available.

I think the TIFF and PNG formats support EXIF data as well, you could try looking for a portable library supporting EXIF.

I agree with you, but in this case i have to do it in a M4. I will continue to search for libraries. Thank you very much

as @Ozone​ said, the format of a .jpg file does not depend on what filesystem or OS you use.

So you should be able to look at open-source libraries, see what they do, and port that to any other target - it's just a matter of manipulating the binary data.

You may need a good understanding of the .jpg file format ...

https://en.wikipedia.org/wiki/JPEG

https://docs.oracle.com/javase/8/docs/api/javax/imageio/metadata/doc-files/jpeg_metadata.html

First of all, thanks for answering. The thing is that i have been searching for some libraries, like libexif, but i can only find these solutions for Unyx systems. I dont find any implementation for a mcu, any example for arduino, mplab, stm...So i am thinking that maybe is a bit difficult to implement this functionality by hand...One possible solution for me could be to store the jpg and also store another file on the SD which would contain the info related to the image, but i find this solution a bit ugly..

I would suggest to look into portable graphic libs in more detail.

Most of those are basically container formats, and you need a library support for the (specified) optional EXIF container.

I didn't look into it, but I suspect an EXIF library is the reverse - adding EXIF "chunks" to a variety of graphics formats.

To be honest i am not sure i am understanding you. The thing here is that i have a SPI Camera, and i need to store these images locally in a SD card, but besides i have to send them through GPRS to another application. Along with the images i have to add some info related to them that is important for the application. I was considering using the metadata of the image because in that way i could have only the image file in the SD and i did not have to explain anything to the application developers, apart from saying that the info is going to be in X metadata field of the image. If i can not edit the meta data fields i have to store that info in another file and i have to send the image and the file and explain them how to link one image with its corresponding info. But i have to use a standard image format in order to be able to extract the SD card and watch the images in a computer

I don't recall the JPG format and packets of data within it being particularly complicated. Can't be that hard to use FatFs, which can handle byte level seek, read and write, to modify or add sections.

Find a programmer, or someone who can pull salient points from an existing library into a smaller footprint / MCU platform.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..