As far as I could tell, extracting jpegs from id3v2 tags wasn't working before (at least, in some situations?).
The problem seemed to be, whenever \xFF\xD8 wasn't in the expected position after the unpack call, real_start = pic =~ start always returned nil, since the start regex started with an ^.
It seems that PNGs would have had the same issue, so I made the same change there.
In addition, expecting \377 as the start of a jpeg didn't seem to work for my mp3s, and \xFF\xD8 worked better (according to my google searches, jpegs do indeed always start with FF D8).
As far as I could tell, extracting jpegs from id3v2 tags wasn't working before (at least, in some situations?).
The problem seemed to be, whenever \xFF\xD8 wasn't in the expected position after the
unpack
call,real_start = pic =~ start
always returned nil, since thestart
regex started with an^
.It seems that PNGs would have had the same issue, so I made the same change there.
In addition, expecting
\377
as the start of a jpeg didn't seem to work for my mp3s, and\xFF\xD8
worked better (according to my google searches, jpegs do indeed always start with FF D8).