diff --git a/coders/jpeg.c b/coders/jpeg.c
index 485f786..a45abc9 100644
--- a/coders/jpeg.c
+++ b/coders/jpeg.c
@@ -1788,8 +1788,8 @@
         Set image resolution.
       */
       jpeg_info.write_JFIF_header=MagickTrue;
-      jpeg_info.X_density=(UINT16) image->x_resolution;
-      jpeg_info.Y_density=(UINT16) image->y_resolution;
+      jpeg_info.X_density=(UINT16) floor(image->x_resolution+0.5);
+      jpeg_info.Y_density=(UINT16) floor(image->y_resolution+0.5);
       if (image->units == PixelsPerInchResolution)
         jpeg_info.density_unit=(UINT8) 1;
       if (image->units == PixelsPerCentimeterResolution)