diff --git a/include/boost/gil/extension/io/formats/tiff/reader_backend.hpp b/include/boost/gil/extension/io/formats/tiff/reader_backend.hpp index 050255e5b..5bc957c6c 100644 --- a/include/boost/gil/extension/io/formats/tiff/reader_backend.hpp +++ b/include/boost/gil/extension/io/formats/tiff/reader_backend.hpp @@ -101,6 +101,13 @@ public: io_error_if( !_io_dev.template get_property< tiff_tile_length >( _info._tile_length ) , "cannot read tiff_tile_length tag." ); } + + io_error_if( _io_dev.template get_property ( _info._resolution_unit) == false + , "cannot read tiff tag"); + io_error_if( _io_dev. template get_property( _info._x_resolution ) == false + , "cannot read tiff tag" ); + io_error_if( _io_dev. template get_property( _info._y_resolution ) == false + , "cannot read tiff tag" ); } /// Check if image is large enough. diff --git a/include/boost/gil/extension/io/formats/tiff/writer_backend.hpp b/include/boost/gil/extension/io/formats/tiff/writer_backend.hpp index d96bdf285..1bbe55343 100644 --- a/include/boost/gil/extension/io/formats/tiff/writer_backend.hpp +++ b/include/boost/gil/extension/io/formats/tiff/writer_backend.hpp @@ -116,9 +116,10 @@ protected: // write rows per strip this->_io_dev.template set_property( this->_io_dev.get_default_strip_size() ); - // x, y resolution - this->_io_dev.template set_property( this->_info._x_resolution ); - this->_io_dev.template set_property( this->_info._y_resolution ); + // write x, y resolution and units + this->_io_dev.template set_property( this->_info._resolution_unit ); + this->_io_dev.template set_property( this->_info._x_resolution ); + this->_io_dev.template set_property( this->_info._y_resolution ); } diff --git a/include/boost/gil/extension/io/tiff_tags.hpp b/include/boost/gil/extension/io/tiff_tags.hpp index b4ef467db..2a29dd5c8 100644 --- a/include/boost/gil/extension/io/tiff_tags.hpp +++ b/include/boost/gil/extension/io/tiff_tags.hpp @@ -125,7 +125,13 @@ struct tiff_x_resolution : tiff_property_base< float, TIFFTAG_XRESOLUTION > {}; struct tiff_y_resolution : tiff_property_base< float, TIFFTAG_YRESOLUTION > {}; /// Defines type for resolution unit property. -struct tiff_resolution_unit : tiff_property_base< uint16_t, TIFFTAG_RESOLUTIONUNIT > {}; + enum class tiff_resolution_unit_value: std:: uint16_t { + NONE = RESUNIT_NONE, + INCH = RESUNIT_INCH, + CENTIMETRE = RESUNIT_CENTIMETER + }; + struct tiff_resolution_unit : tiff_property_base< tiff_resolution_unit_value, TIFFTAG_RESOLUTIONUNIT > { + }; /// Defines type for planar configuration property. struct tiff_planar_configuration : tiff_property_base< uint16_t, TIFFTAG_PLANARCONFIG > {}; @@ -218,6 +224,10 @@ struct image_read_info< tiff_tag > , _tile_width ( 0 ) , _tile_length( 0 ) + + , _x_resolution( 0 ) + , _y_resolution( 0 ) + , _resolution_unit( tiff_resolution_unit_value:: NONE ) {} /// The number of rows of pixels in the image. @@ -247,6 +257,10 @@ struct image_read_info< tiff_tag > tiff_tile_width::type _tile_width; /// Tile length tiff_tile_length::type _tile_length; + + tiff_x_resolution::type _x_resolution; + tiff_y_resolution::type _y_resolution; + tiff_resolution_unit::type _resolution_unit; }; /// Read settings for tiff images. @@ -279,9 +293,9 @@ struct image_read_settings< tiff_tag > : public image_read_settings_base tiff_directory::type _directory; }; -/// Read settings for tiff images. +/// Write settings for tiff images. /// -/// The structure can be used for all read_xxx functions, except read_image_info. +/// The structure can be used for all write_xxx functions, except write_image_info. template< typename Log > struct image_write_info< tiff_tag, Log > { @@ -298,6 +312,7 @@ struct image_write_info< tiff_tag, Log > , _tile_length ( 0 ) , _x_resolution ( 0 ) , _y_resolution ( 0 ) + , _resolution_unit ( tiff_resolution_unit_value::NONE ) {} /// The color space of the image data. @@ -321,6 +336,7 @@ struct image_write_info< tiff_tag, Log > /// x, y resolution tiff_x_resolution::type _x_resolution; tiff_y_resolution::type _y_resolution; + tiff_resolution_unit::type _resolution_unit; /// A log to transcript error and warning messages issued by libtiff. Log _log;