tiff density in 8bim
Posted: 2010-11-04T05:46:45-07:00
I have found some problems when dealing with tiff density. I have a tiff file where tiff tags set units in cm, but 8bim profile is written in inches. Imagemagick loads tiff tags, and then modifies only the values but not the units when loading the 8bim profile.
In magick/profile.c, x_resolution and y_resolution is modified, but units are not:
Same code from gimp, in plug-ins/file-psd/psd-image-res-load.c:
Is this a bug or done on purpose?
See also http://answers.google.com/answers/threa ... 88091.html
In magick/profile.c, x_resolution and y_resolution is modified, but units are not:
Code: Select all
1554 case 0x03ed:
1555 {
1556 unsigned short
1557 resolution;
1558
1559 /*
1560 Resolution.
1561 */
1562 p=ReadResourceShort(p,&resolution)+6;
1563 image->x_resolution=(double) resolution;
1564 p=ReadResourceShort(p,&resolution)+6;
1565 image->y_resolution=(double) resolution;
1566 break;
1567 }
Code: Select all
491 static gint
492 load_resource_1005 (const PSDimageres *res_a,
493 const gint32 image_id,
494 FILE *f,
495 GError **error)
496 {
497 /* Load image resolution and unit of measure */
498
499 /* FIXME width unit and height unit unused at present */
500
501 ResolutionInfo res_info;
502 GimpUnit image_unit;
503
504 IFDBG(2) g_debug ("Process image resource block 1005: Resolution Info");
505
506 if (fread (&res_info.hRes, 4, 1, f) < 1
507 || fread (&res_info.hResUnit, 2, 1, f) < 1
508 || fread (&res_info.widthUnit, 2, 1, f) < 1
509 || fread (&res_info.vRes, 4, 1, f) < 1
510 || fread (&res_info.vResUnit, 2, 1, f) < 1
511 || fread (&res_info.heightUnit, 2, 1, f) < 1)
512 {
513 psd_set_error (feof (f), errno, error);
514 return -1;
515 }
516 res_info.hRes = GINT32_FROM_BE (res_info.hRes);
517 res_info.hResUnit = GINT16_FROM_BE (res_info.hResUnit);
518 res_info.widthUnit = GINT16_FROM_BE (res_info.widthUnit);
519 res_info.vRes = GINT32_FROM_BE (res_info.vRes);
520 res_info.vResUnit = GINT16_FROM_BE (res_info.vResUnit);
521 res_info.heightUnit = GINT16_FROM_BE (res_info.heightUnit);
522
523 IFDBG(3) g_debug ("Resolution: %d, %d, %d, %d, %d, %d",
524 res_info.hRes,
525 res_info.hResUnit,
526 res_info.widthUnit,
527 res_info.vRes,
528 res_info.vResUnit,
529 res_info.heightUnit);
530
531 /* Resolution always recorded as pixels / inch in a fixed point implied
532 decimal int32 with 16 bits before point and 16 after (i.e. cast as
533 double and divide resolution by 2^16 */
534 gimp_image_set_resolution (image_id,
535 res_info.hRes / 65536.0, res_info.vRes / 65536.0);
536
537 /* GIMP only has one display unit so use ps horizontal resolution unit */
538 switch (res_info.hResUnit)
539 {
540 case PSD_RES_INCH:
541 image_unit = GIMP_UNIT_INCH;
542 break;
543 case PSD_RES_CM:
544 image_unit = GIMP_UNIT_MM;
545 break;
546 default:
547 image_unit = GIMP_UNIT_INCH;
548 }
549
550 gimp_image_set_unit (image_id, image_unit);
551
552 return 0;
553 }
See also http://answers.google.com/answers/threa ... 88091.html