The present invention relates to a process for preparing nanoparticles of a polysaccharide crosslinked with a suitable crosslinking agent, inside which a gadolinium- or manganese-based contrast agent is geometrically confined; this process of preparation is based on the use of microfluidic devices and on the control of temperatures, flows and respective concentrations in the several steps of the process, so as to obtain a final product having nanometric size wherein the metal, thanks to its geometric confinement in the crosslinked polysaccharide lattice, has an increased relaxivity, useful for increasing the contrast of images in the magnetic resonance imaging, or in combination with other imaging diagnostic techniques or more in general in nuclear medicine.