Defining JPG DPI and Bit Depth Parameters
[email protected] ("Miguel Maldonado")
| Newsgroups | php.gd.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi, I'm new to using the gd library. My goal is to batch resize a large number of jpg images. Using the examples in the documentation I can easily reduce the size of the images but I'm not able to maintain the values for the DPI and the Bit Depth for the image. While the original image has a DPI of 200 and a Bit Depth of 1 the resized image has the default resolution of 96 and a Bit Depth of 8. I'm using the following code: gdImagePtr im_in; gdImagePtr im_out; FILE *in; FILE *out; int new_heigth; /* Load a small png to expand in the larger one */ in = fopen(jpg_in, "rb"); im_in = gdImageCreateFromJpeg(in); fclose(in); new_heigth = (int) new_width * ((double)im_in->sy /im_in->sx ); /* Make the output image */ im_out = gdImageCreate(new_width, new_heigth); /* Now copy the smaller image, but four times larger */ gdImageCopyResized(im_out, im_in, 0, 0, 0, 0, im_out->sx, im_out->sy, im_in->sx, im_in->sy); out = fopen(jpg_out, "wb"); gdImageJpeg(im_out, out, -1); fclose(out); gdImageDestroy(im_in); gdImageDestroy(im_out); Thanks in advance, Miguel Maldonado