How can I export a note from obsidian to a markdown file preserving the pictures?

Obsidian consists of markdown files, so you don’t have to export anything.

Change your Setting → Files and links → Link format to “absolute path” or “relative path”.