Skip to content

Commit 485c42c

Browse files
committed
Correct parsing of the density
1 parent aed7b30 commit 485c42c

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

coders/jpeg.c

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1156,8 +1156,7 @@ static Image *ReadJPEGImage_(const ImageInfo *image_info,
11561156
*p;
11571157

11581158
size_t
1159-
max_memory_to_use,
1160-
units;
1159+
max_memory_to_use;
11611160

11621161
ssize_t
11631162
y;
@@ -1251,20 +1250,17 @@ static Image *ReadJPEGImage_(const ImageInfo *image_info,
12511250
/*
12521251
Set image resolution.
12531252
*/
1254-
units=0;
1255-
if (jpeg_info->saw_JFIF_marker != 0)
1253+
if ((jpeg_info->saw_JFIF_marker != 0) && (jpeg_info->density_unit != 0))
12561254
{
1255+
if (jpeg_info->density_unit == 1)
1256+
image->units=PixelsPerInchResolution;
1257+
else if (jpeg_info->density_unit == 2)
1258+
image->units = PixelsPerCentimeterResolution;
12571259
if (jpeg_info->X_density != 0)
12581260
image->x_resolution=(double) jpeg_info->X_density;
12591261
if (jpeg_info->Y_density != 0)
12601262
image->y_resolution=(double) jpeg_info->Y_density;
1261-
if (jpeg_info->density_unit != 0)
1262-
units=(size_t) jpeg_info->density_unit;
12631263
}
1264-
if (units == 1)
1265-
image->units=PixelsPerInchResolution;
1266-
if (units == 2)
1267-
image->units=PixelsPerCentimeterResolution;
12681264
number_pixels=(MagickSizeType) image->columns*image->rows;
12691265
option=GetImageOption(image_info,"jpeg:size");
12701266
if ((option != (const char *) NULL) &&

0 commit comments

Comments
 (0)