PHP-ID3
PHP-ID3 copied to clipboard
getImage not working
When i try to file_puts_content result of getImage() this is not working. Images are broken.
getImage() returns an array of mimeType and binary data. Are you sure you are outputting the binary data with correct mime type? If yes, can you describe the mp3 file you are having problem with.
All mp3-files are incorrect analyzing.
$reader = getId3Tag...; list($mime, $image) = $reader->getImage(); file_put_contents('test.png', $image);
And file test.png is broken.
Correct me if wrong, but you are trying to output it in "PNG" format without considering the MIME type. The library performs no conversions and the images can only be outputted in the format they have been stored.
They have been stored in format image/png. I know this, because i try export this with other library that works fine.
@shubhamjain , @Max201 is right the binary file reader returns image data skipping the first byte. Check it on your hex editor. In example for image/jpg files start the file at 0xD8 [..] instead of 0xFF 0xD8