plug-ins: Read TIFF resolution correctly

Resolves #12468
In a2458f15, we converted xres and yres to gdouble since
gimp_image_get_resolution () requires doubles as arguments.
However, TIFFGetField () expects a float, and returns incorrect
values if a double is used as a parameter.

This patch converts xres and yres back to gfloat, and makes
new default_xres and default_yres variables as gdoubles to
use with gimp_image_get_resolution ().
This commit is contained in:
Alx Sa 2024-11-26 02:56:54 +00:00
parent 6a820e946f
commit 10b32c35b6

View file

@ -1303,8 +1303,8 @@ load_image (GimpProcedure *procedure,
/* any resolution info in the file? */
{
gdouble xres = 72.0;
gdouble yres = 72.0;
gfloat xres = 72.0;
gfloat yres = 72.0;
gushort read_unit = RESUNIT_NONE;
GimpUnit *unit = gimp_unit_pixel (); /* invalid unit */
@ -1360,6 +1360,7 @@ load_image (GimpProcedure *procedure,
* the resolution at all. Gimp will then use the default
* set by the user
*/
if (read_unit != RESUNIT_NONE)
{
if (! isfinite (xres) ||
@ -1367,11 +1368,17 @@ load_image (GimpProcedure *procedure,
! isfinite (yres) ||
yres < GIMP_MIN_RESOLUTION || yres > GIMP_MAX_RESOLUTION)
{
gdouble default_xres = 0.0;
gdouble default_yres = 0.0;
g_message (_("Invalid image resolution info, using default"));
/* We need valid xres and yres for computing
* layer_offset_x_pixel and layer_offset_y_pixel.
*/
gimp_image_get_resolution (*image, &xres, &yres);
gimp_image_get_resolution (*image,
&default_xres, &default_yres);
xres = (gfloat) default_xres;
yres = (gfloat) default_yres;
}
else
{