lib/zpng/cli.rb in zpng-0.4.3 vs lib/zpng/cli.rb in zpng-0.4.4

- old
+ new

@@ -177,17 +177,19 @@ def info color = %w'COLOR_GRAYSCALE COLOR_RGB COLOR_INDEXED COLOR_GRAY_ALPHA COLOR_RGBA'.find do |k| @img.hdr.color == ZPNG.const_get(k) end - puts "[.] image size #{@img.width || '?'}x#{@img.height || '?'}, #{@img.bpp}bpp, #{color}" + puts "[.] image size #{@img.width || '?'}x#{@img.height || '?'}, #{@img.bpp || '?'}bpp, #{color}" puts "[.] palette = #{@img.palette}" if @img.palette - puts "[.] uncompressed imagedata size = #{@img.imagedata_size} bytes" + puts "[.] uncompressed imagedata size = #{@img.imagedata_size || '?'} bytes" _conditional_hexdump(@img.imagedata, 3) if @options[:verbose] > 0 end def _conditional_hexdump data, v2 = 2 + return unless data + if @options[:verbose] <= 0 # do nothing elsif @options[:verbose] < v2 sz = 0x20 print Hexdump.dump(data[0,sz], @@ -219,10 +221,14 @@ else 'CRC ERROR'.red end puts "[.] #{chunk.inspect(@options[:verbose]).sub(chunk.type, colored_type)} #{colored_crc}" - _conditional_hexdump(chunk.data) unless chunk.size == 0 + if @options[:verbose] >= 3 + _conditional_hexdump(chunk.export(fix_crc: false)) + else + _conditional_hexdump(chunk.data) + end end end def ascii @img.height.times do |y|