class WahWah::ID3::ImageFrameBody

Constants

TYPES

Public Instance Methods

mime_type() click to toggle source
# File lib/wahwah/id3/image_frame_body.rb, line 30
def mime_type
  mime_type = @mime_type.downcase.yield_self { |type| type == 'jpg' ? 'jpeg' : type }
  @version > 2 ? mime_type : "image/#{mime_type}"
end
parse() click to toggle source

ID3v2.2 image frame structure:

Text encoding $xx Image format $xx xx xx Picture type $xx Description <text string according to encoding> $00 (00) Picture data <binary data>

ID3v2.3 and ID3v2.4 image frame structure:

Text encoding $xx MIME type <text string> $00 Picture type $xx Description <text string according to encoding> $00 (00) Picture data <binary data>

# File lib/wahwah/id3/image_frame_body.rb, line 50
def parse
  frame_format = @version > 2 ? 'CZ*Ca*' : 'Ca3Ca*'
  encoding_id, @mime_type, type_index, reset_content = @content.unpack(frame_format)
  encoding = ENCODING_MAPPING[encoding_id]
  _description, data = Helper.split_with_terminator(reset_content, ENCODING_TERMINATOR_SIZE[encoding])

  @value = { data: data, mime_type: mime_type, type: TYPES[type_index] }
end