Displays information about the image e.g. dimensions, aspect ratio, etc.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(format_pnm), | intent(in) | :: | this |
elemental impure subroutine print_info(this) class(format_pnm), intent(in) :: this real(rk) :: avg, avg_red, avg_green, avg_blue real(rk) :: asp_ratio real(rk) :: pixel_size_kb, pixel_size_mb select case (this%file_format) case ('pbm', 'pgm') call average_colors(this, avg) case ('ppm') call average_colors(this, avg, avg_red, avg_green, avg_blue) end select call aspect_ratio(this, asp_ratio) call pixel_size(this, pixel_size_kb, pixel_size_mb) print '(a)' , 'Image Information:' print '(a)' , '-------------------------------------------' print '(a, g0)' , 'Magic Number: ', this%magic_number print '(a, a)' , 'File Format : ', this%file_format print '(a, a)' , 'Encoding : ', this%encoding print '(a, a)' , 'Comment : ', trim(this%comment) print '(a, a, g0, a, g0)' , 'Dimensions : ', 'Height: ', this%height, ' Width: ', this%width print '(a, g0)' , 'Total Pixels: ', this%width * this%height print '(a, f6.2)' , 'Aspect Ratio: ', asp_ratio print '(a, f8.2, a, f8.2, a)' , 'Pixel Size : ', pixel_size_kb, ' KB ', pixel_size_mb, ' MB' select case (this%file_format) case ('pbm', 'pgm') print '(a, g0)' , 'Average : ', avg case ('ppm') print '(a, g0)' , 'Max Color : ', this%max_color print '(a, a, f6.2, a, f6.2, a, f6.2)', 'Average RGB : ', 'R:', avg_red, ' G:', avg_green, ' B:', avg_blue end select print '(a)' , '-------------------------------------------' end subroutine print_info