As of jpeg-7, the scale coefficents may be set to non-unitary values by the initial DCT transform. This caused the original already-scale detection algorithm in xli to break. To avoid this, set the already-scaled marker when we adjust the scale fraction (that gets passed into the DCT). Signed-off-by: Robin H. Johnson diff -Nuar -X x xli-2005-02-27.orig/jpeg.c xli-2005-02-27/jpeg.c --- xli-2005-02-27.orig/jpeg.c 2005-02-27 16:42:39.000000000 -0800 +++ xli-2005-02-27/jpeg.c 2009-09-05 15:02:12.462635389 -0700 @@ -211,7 +211,7 @@ xli_jpg_err jerr; Image *image = 0; byte **rows = 0; - int i, rowbytes; + int i, rowbytes, flags; CURRFUNC("jpegLoad"); zfp = zopen(fullname); @@ -248,9 +248,13 @@ if (verbose) describe_jpeg(&cinfo, fullname); + flags = 0; if (image_ops->iscale > 0 && image_ops->iscale < 4) { - cinfo.scale_num = 1; - cinfo.scale_denom = 1 << image_ops->iscale; + flags |= FLAG_ISCALE; + //cinfo.scale_num = 1; + cinfo.scale_denom *= 1 << image_ops->iscale; + if (verbose) + printf("scaling to %d/%d\n", cinfo.scale_num, cinfo.scale_denom); } else if (image_ops->iscale_auto) { image_ops->iscale = 0; while (image_ops->iscale < 3 && (cinfo.image_width >> @@ -258,9 +262,11 @@ cinfo.image_height >> image_ops->iscale > globals.dinfo.height * .9)) image_ops->iscale += 1; - cinfo.scale_denom = 1 << image_ops->iscale; + cinfo.scale_denom *= 1 << image_ops->iscale; + if(image_ops->iscale > 0) + flags |= FLAG_ISCALE; if (verbose) - printf("auto-scaling to 1/%d\n", cinfo.scale_denom); + printf("auto-scaling to %d/%d\n", cinfo.scale_num, cinfo.scale_denom); } znocache(zfp); @@ -288,8 +294,7 @@ } image->gamma = RETURN_GAMMA; - if (cinfo.scale_denom > 1) - image->flags |= FLAG_ISCALE; + image->flags |= flags; rowbytes = cinfo.output_width * cinfo.output_components; assert(image->pixlen * image->width == rowbytes);