From: cristy Date: Mon, 14 Sep 2009 02:20:04 +0000 (+0000) Subject: (no commit message) X-Git-Tag: 7.0.1-0~10699 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=caec74e9e40b5bf3b1bfc9306130bd91a6e35b02;p=imagemagick --- diff --git a/coders/jpeg.c b/coders/jpeg.c index 34bb36da3..db67c3bdf 100644 --- a/coders/jpeg.c +++ b/coders/jpeg.c @@ -848,6 +848,9 @@ static Image *ReadJPEGImage(const ImageInfo *image_info, char value[MaxTextExtent]; + const char + *property; + ErrorManager error_manager; @@ -956,20 +959,33 @@ static Image *ReadJPEGImage(const ImageInfo *image_info, if (units == 2) image->units=PixelsPerCentimeterResolution; number_pixels=(MagickSizeType) image->columns*image->rows; - if (image_info->size != (char *) NULL) + property=GetImageProperty(image,"jpeg:scale"); + if (property != (const char *) NULL) { double scale_factor; + GeometryInfo + geometry_info; + + int + flags; + /* - Let the JPEG library subsample for us. + Scale the image. */ + flags=ParseGeometry(property,&geometry_info); + if ((flags & SigmaValue) == 0) + geometry_info.sigma=geometry_info.rho; jpeg_calc_output_dimensions(&jpeg_info); image->magick_columns=jpeg_info.output_width; image->magick_rows=jpeg_info.output_height; - scale_factor=(double) jpeg_info.output_width/image->columns; - if (scale_factor > ((double) jpeg_info.output_height/image->rows)) - scale_factor=(double) jpeg_info.output_height/image->rows; + scale_factor=1.0; + if (geometry_info.rho != 0.0) + scale_factor=jpeg_info.output_width/geometry_info.rho; + if ((geometry_info.sigma != 0.0) && + (scale_factor > (jpeg_info.output_height/geometry_info.sigma))) + scale_factor=jpeg_info.output_height/geometry_info.sigma; jpeg_info.scale_num=1U; jpeg_info.scale_denom=(unsigned int) scale_factor; jpeg_calc_output_dimensions(&jpeg_info);