summaryrefslogtreecommitdiff
path: root/src/gd_jpeg.c
diff options
context:
space:
mode:
authortabe <none@none>2009-03-08 09:16:04 +0000
committertabe <none@none>2009-03-08 09:16:04 +0000
commitf40454c1b307c92e5c111671c0f12a7ae26eecb8 (patch)
treeac64628926500e4d6c67e660db1f9cced4bf67d2 /src/gd_jpeg.c
parent02ae7c20079a64e8c809108deb1a0d50d816c9dd (diff)
downloadlibgd-f40454c1b307c92e5c111671c0f12a7ae26eecb8.tar.gz
ref FS#176: added support of variable resolution by Alan Boudreault.
Diffstat (limited to 'src/gd_jpeg.c')
-rw-r--r--src/gd_jpeg.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/gd_jpeg.c b/src/gd_jpeg.c
index 1e21ad7..2f48c9a 100644
--- a/src/gd_jpeg.c
+++ b/src/gd_jpeg.c
@@ -160,6 +160,10 @@ BGD_DECLARE(void) gdImageJpegCtx(gdImagePtr im, gdIOCtx *outfile, int quality)
jpeg_set_defaults(&cinfo);
+ cinfo.density_unit = 1;
+ cinfo.X_density = im->res_x;
+ cinfo.Y_density = im->res_y;
+
if(quality >= 0) {
jpeg_set_quality(&cinfo, quality, TRUE);
}
@@ -358,6 +362,18 @@ BGD_DECLARE(gdImagePtr) gdImageCreateFromJpegCtx(gdIOCtx *infile)
goto error;
}
+ /* check if the resolution is specified */
+ switch (cinfo.density_unit) {
+ case 1:
+ im->res_x = cinfo.X_density;
+ im->res_y = cinfo.Y_density;
+ break;
+ case 2:
+ im->res_x = DPCM2DPI(cinfo.X_density);
+ im->res_y = DPCM2DPI(cinfo.Y_density);
+ break;
+ }
+
/* 2.0.22: very basic support for reading CMYK colorspace files. Nice for
* thumbnails but there's no support for fussy adjustment of the
* assumed properties of inks and paper.