Fix T84661: read jpg pixel density
For jpeg, an image.resolution was always based on the default 72dpi, now read the pixel density from the jpeg_decompress_struct, convert according to unit and store in IMBuf's ppm. Not 100% sure of all implications tbh., files I have checked seem to work as expected now in the context of the report. Maniphest Tasks: T84661 Differential Revision: https://developer.blender.org/D10166
This commit is contained in:
parent
3fb5e83867
commit
6f88053d85
Notes:
blender-bot
2023-02-14 04:39:18 +01:00
Referenced by issue #87857, wrong image resolution (dpi) reported for certain jpg files from Photoshop Referenced by issue #84661, Can't read metadata data (EXIF) information in JPEG files
|
@ -413,11 +413,22 @@ static ImBuf *ibJpegImageFromCinfo(struct jpeg_decompress_struct *cinfo, int fla
|
|||
jpeg_finish_decompress(cinfo);
|
||||
}
|
||||
|
||||
jpeg_destroy((j_common_ptr)cinfo);
|
||||
if (ibuf) {
|
||||
/* Density_unit may be 0 for unknown, 1 for dots/inch, or 2 for dots/cm. */
|
||||
if (cinfo->density_unit == 1) {
|
||||
/* Convert inches to meters. */
|
||||
ibuf->ppm[0] = cinfo->X_density / 0.0254f;
|
||||
ibuf->ppm[1] = cinfo->Y_density / 0.0254f;
|
||||
}
|
||||
else if (cinfo->density_unit == 2) {
|
||||
ibuf->ppm[0] = cinfo->X_density * 100.0f;
|
||||
ibuf->ppm[1] = cinfo->Y_density * 100.0f;
|
||||
}
|
||||
|
||||
ibuf->ftype = IMB_FTYPE_JPG;
|
||||
ibuf->foptions.quality = MIN2(ibuf_quality, 100);
|
||||
}
|
||||
jpeg_destroy((j_common_ptr)cinfo);
|
||||
}
|
||||
|
||||
return ibuf;
|
||||
|
|
Loading…
Reference in New Issue