Display image in browser with getID3

Nick

I want to create a php file that will return an image of an mp3 song when called as the src parameter in the img tag of html. Something like this:

<img src="/imageReturn.php?song=SongName">

In order to get the image from the mp3 file I used the getID3 library. My PHP code:

$song= $_GET["song"];
require_once("getID3-1.9.15/getid3/getid3.php");
$Path=$song.".mp3";

$getID3 = new getID3;
$OldThisFileInfo = $getID3->analyze($Path);
if(isset($OldThisFileInfo['comments']['picture'][0]))
{
    $ImageBase='data:'.$OldThisFileInfo['comments']['picture'][0]['image_mime'].';charset=utf-8;base64,'.base64_encode($OldThisFileInfo['comments']['picture'][0]['data']);
}

header('Content-Type: image/jpeg');
echo $ImageBase;

The problem is that I cant get php display the image. How to fix it?

Syscall

You don't have to encode the image to base64, you can directly echo the image data.

$getID3 = new getID3;
$OldThisFileInfo = $getID3->analyze($Path);
if(isset($OldThisFileInfo['comments']['picture'][0]))
{
    header('Content-Type: ' . $OldThisFileInfo['comments']['picture'][0]['image_mime']);
    echo $OldThisFileInfo['comments']['picture'][0]['data'];
    die;
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Browser will not display image

From Dev

Display image in browser

From Dev

Not able to display image in the browser for a simple express code

From Dev

Display Browser Image within Canvas in React

From Dev

Display image at 100% width or as big as fits in browser

From Dev

How to display Base64 image on browser

From Dev

Image display in the Browser issue using php

From Dev

Image won't display in browser using html

From Dev

Is there a way to display an image in the browser without having a preview of the image in the developer tools?

From Dev

getId3 to get video duration in seconds

From Dev

How to use getid3 if installed with apt-get install getid3?

From Dev

Display the image in the browser without any extension & path of directory

From Dev

Display spinning wheel/circle image on browser during long running operation

From Dev

Download an image generated dynamically rather than display in browser

From Dev

How to display image downloaded from cloud storage in the browser?

From Dev

How to display high resolution image in browser using openlayers

From Java

How to display an image/gif in a browser through a Java Web Server

From Dev

How can I display png data as an image inside in the browser?

From Dev

Can't display image on browser with django rest framework

From Dev

IE: Background Image does not display. Browser repaints on hover?

From Dev

Convert base64 to image and display on browser only

From Dev

unable to display the background image to full screen of the browser and make it responsive

From Dev

How to display EMF (MS Enhanced Meta File) image in browser?

From Dev

How to write my node.js code to display an image on browser

From Dev

The browser opens the image when its path is typed in address-bar, but does Not display it as background-image. Why?

From Dev

Unable to view an image in S3 in browser

From Dev

How do I display an image in browser using a web server in C using fread?

From Java

How can I return a byte array as an image from a Spring Controller, so that a browser can display it?

From Dev

Content url does not display image on firefox browser, is there a work around that doesn't require removing alt tags?

Related Related

  1. 1

    Browser will not display image

  2. 2

    Display image in browser

  3. 3

    Not able to display image in the browser for a simple express code

  4. 4

    Display Browser Image within Canvas in React

  5. 5

    Display image at 100% width or as big as fits in browser

  6. 6

    How to display Base64 image on browser

  7. 7

    Image display in the Browser issue using php

  8. 8

    Image won't display in browser using html

  9. 9

    Is there a way to display an image in the browser without having a preview of the image in the developer tools?

  10. 10

    getId3 to get video duration in seconds

  11. 11

    How to use getid3 if installed with apt-get install getid3?

  12. 12

    Display the image in the browser without any extension & path of directory

  13. 13

    Display spinning wheel/circle image on browser during long running operation

  14. 14

    Download an image generated dynamically rather than display in browser

  15. 15

    How to display image downloaded from cloud storage in the browser?

  16. 16

    How to display high resolution image in browser using openlayers

  17. 17

    How to display an image/gif in a browser through a Java Web Server

  18. 18

    How can I display png data as an image inside in the browser?

  19. 19

    Can't display image on browser with django rest framework

  20. 20

    IE: Background Image does not display. Browser repaints on hover?

  21. 21

    Convert base64 to image and display on browser only

  22. 22

    unable to display the background image to full screen of the browser and make it responsive

  23. 23

    How to display EMF (MS Enhanced Meta File) image in browser?

  24. 24

    How to write my node.js code to display an image on browser

  25. 25

    The browser opens the image when its path is typed in address-bar, but does Not display it as background-image. Why?

  26. 26

    Unable to view an image in S3 in browser

  27. 27

    How do I display an image in browser using a web server in C using fread?

  28. 28

    How can I return a byte array as an image from a Spring Controller, so that a browser can display it?

  29. 29

    Content url does not display image on firefox browser, is there a work around that doesn't require removing alt tags?

HotTag

Archive