W
W
Wasya UK2017-05-13 16:46:23
JavaScript
Wasya UK, 2017-05-13 16:46:23

How to find out the encoding of an encrypted image and is it correct?

I'm trying to make it possible to access the icon of an audio file, but the resulting picture is encoded. It doesn’t look like base64, but I didn’t find anything similar on the Internet (Maybe it’s not even a picture?
I seem to get all the necessary data

{ title: 'Название песни',
  artist: [ 'Певец' ],
  albumartist: [ 'Певец' ],
  album: 'Тут альбом ',
  year: '2015',
  track: { no: 96, of: 114 },
  genre: [ 'Тут жанр' ],
  disk: { no: 6, of: 6 },
  ...

The code:
var parser = mm(fs.createReadStream('Путь к аудио'), function (err, metadata{
    if (err) throw err;

    console.log(metadata.picture);
});

Outputs the following:
{ format: 'jpg',
  data: <Buffer ff d8 ff e1 00 a1 45 78 69 66 00 00 49 49 2a 00 08 00 00 00 05 00 12 01 03 00 01 00 00 00 01 00 00 00 31 01 02 00 0d 00 00 00 4a 00 00 00 32 01 02 00 ... > }

Is this an encoded image at all? if so, how to decode it for use in further binding to css?
Thanks in advance

Answer the question

In order to leave comments, you need to log in

2 answer(s)
W
Wasya UK, 2017-05-13
@dmc1989

This buffer can be decoded as follows:
Buffer:
To paste in css:
Used - npm musicmetadata

1
15432, 2017-05-13
@15432

The usual hexadecimal representation of the file.
Just bytes written in text.
These FF D8 FF ... you need to convert to data. (well, or this is how the logger prints them, but in fact it is already in the right form)
FF D8 is exactly the beginning of the JPG header.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question