I may have found the solution : simply add a 2px transparent margin above and below the image and colors are not changed in dark mode.