to their source.
Resolves: https://rt.cpan.org/Ticket/Display.html?id=8520
- the tiff reader now puts warning messages produced during reading into
the i_warning tag.
Resolves: https://rt.cpan.org/Ticket/Display.html?id=8722
+- the i_xres and i_yres tags are now stored in a resolution similar
+ to their source.
+ Resolves: https://rt.cpan.org/Ticket/Display.html?id=8520
=================================================================
else if (yres && !xres)
xres = yres;
if (xres) {
- i_tags_set_float(&im->tags, "i_xres", 0, xres * 0.0254);
- i_tags_set_float(&im->tags, "i_yres", 0, yres * 0.0254);
+ i_tags_set_float2(&im->tags, "i_xres", 0, xres * 0.0254, 4);
+ i_tags_set_float2(&im->tags, "i_yres", 0, yres * 0.0254, 4);
}
i_tags_addn(&im->tags, "bmp_compression", 0, compression);
i_tags_addn(&im->tags, "bmp_important_colors", 0, clr_important);
double *value);
extern int i_tags_set_float(i_img_tags *tags, char const *name, int code,
double value);
+extern int i_tags_set_float2(i_img_tags *tags, char const *name, int code,
+ double value, int places);
extern int i_tags_get_int(i_img_tags *tags, char const *name, int code,
int *value);
extern int i_tags_get_string(i_img_tags *tags, char const *name, int code,
if (png_get_pHYs(png_ptr, info_ptr, &xres, &yres, &unit_type)) {
mm_log((1,"pHYs (%d, %d) %d\n", xres, yres, unit_type));
if (unit_type == PNG_RESOLUTION_METER) {
- i_tags_set_float(&im->tags, "i_xres", 0, xres * 0.0254);
- i_tags_set_float(&im->tags, "i_yres", 0, yres * 0.0254);
+ i_tags_set_float2(&im->tags, "i_xres", 0, xres * 0.0254, 5);
+ i_tags_set_float2(&im->tags, "i_yres", 0, yres * 0.0254, 5);
}
else {
i_tags_addn(&im->tags, "i_xres", 0, xres);
i_tags_delete(&tags, index);
count = i_tags_delbyname(tags, name);
count = i_tags_delbycode(tags, code);
+ if (i_tags_get_float(&tags, name, code, &float_value)) { found }
+ i_tags_set_float(&tags, name, code, value);
+ i_tags_set_float2(&tags, name, code, value, sig_digits);
+ i_tags_get_int(&tags, name, code, &int_value);
=head1 DESCRIPTION
int i_tags_set_float(i_img_tags *tags, char const *name, int code,
double value) {
+ return i_tags_set_float2(tags, name, code, value, 30);
+}
+
+/*
+=item i_tags_set_float2(tags, name, code, value, places)
+
+Sets the tag with the given name and code to the given floating point
+value.
+
+Since tags are strings or ints, we convert the value to a string before
+storage at the precision specified by C<places>.
+
+=cut
+*/
+
+int i_tags_set_float2(i_img_tags *tags, char const *name, int code,
+ double value, int places) {
char temp[40];
- sprintf(temp, "%.30g", value);
+ if (places < 0)
+ places = 30;
+ else if (places > 30)
+ places = 30;
+
+ sprintf(temp, "%.*g", places, value);
if (name)
i_tags_delbyname(tags, name);
else
i_tags_addn(&im->tags, "tiff_resolutionunit", 0, resunit);
if (resunit == RESUNIT_NONE)
i_tags_addn(&im->tags, "i_aspect_only", 0, 1);
- i_tags_set_float(&im->tags, "i_xres", 0, xres);
- i_tags_set_float(&im->tags, "i_yres", 0, yres);
+ /* tifflib doesn't seem to provide a way to get to the original rational
+ value of these, which would let me provide a more reasonable
+ precision. So make up a number. */
+ i_tags_set_float2(&im->tags, "i_xres", 0, xres, 6);
+ i_tags_set_float2(&im->tags, "i_yres", 0, yres, 6);
}
/* Text tags */