![]() |
| Forums | Gaming News | Videos | Downloads | Today's Posts | Mark Forums Read | Chat | FAQ | Members List | Contact |
| ||||||
This is a discussion on Problem with PHP random sig with mp3 embedded image within the Everything Windows forums, part of the General PC Forums category; Ok I'm having a problem with the image generated using a randomsig code. The original image had an mp3 embedded ...
![]() |
|
|
LinkBack | Thread Tools |
|
|
#1 |
![]() Enter Custom Title
|
Ok I'm having a problem with the image generated using a randomsig code. The original image had an mp3 embedded in it:
![]() As you can see, dragging that into Winamp, no problem it plays. Now this is the code I'm using: Code:
<?php
header("Content-Type: image/png");
$sigs = array();
$sigs[] = "http://img267.imageshack.us/img267/7640/sig1box4hk.png";
mt_srand((double)microtime()*1000000);
$sig = $sigs[mt_rand(0, count($sigs)-1)];
$im = ImageCreatefrompng("$sig");
imagealphablending($im, true);
imagesavealpha($im, true);
Imagepng($im);
?>
The randomsig code works but the problem is that the generated php only uses the image data and it loses the mp3 embedded inside of it. Can anyone show me a way of making the output retain the mp3? Oh yeah and thanks Pope for that guide you wrote a while back on embedding an mp3
|
|
|
|
|
|
#2 |
![]() |
No problem
![]() I tested this out: PHP Code:
On displaying the page, it was 20kb which means the mp3 was stripped out. I'm guessing php reads up to the png header and stops. There might be ways to get around this and I am testing them now, I just started learning php a few days ago so I don't know too much about it. Does fwrite work with non text files? -= Double Post =- PHP Code:
You can use your random image code to define $background. After it has created the image, the image is saved as canvaswithtext.png. This image is read along with your MP3 and they are used to create the file result.png which is displayed at the end. As I said, I just started learning PHP a few days ago so there was probably an easier way to do all this. -= Double Post =- **UPDATE** I rewrote it with your random code and removed the text overlay, since I think you don't need it and I misunderstood the first time. I also closed the files, which apparently is good but I don't understand it. PHP Code:
I know nothing about arrays so I guess I can't help with that one. Last edited by PopeOfDope; 01-21-2007 at 06:47 AM.. Reason: Automerged Doublepost |
|
|
|
|
|
#3 |
![]() Enter Custom Title
|
Thanks, I had thought of trying to do that but I couldn't. Now I'm having problem with making the random sig output be usuable but that's alright, I'll figure it out. I onlt relised something though, the mp3 is fixed. A random pic will be written to a definate song, now even if I made the song random the chances of them matching all the time is tiny.
EDIT: Oh I just saw your second edit, one sec. Thanks again ![]() EDIT2: You solved the random image problem, now all I need is to find some way of matching the song up. EDIT3: Damn Imagecreatefrompng strips the mp3, I'm almost sure. |
|
|
|
|
|
#4 | |
![]() |
I was thinking about creating an image array and an MP3 array in matching order e.g. 1.png goes with 1.mp3 etc.
Then you define PHP Code:
PHP Code:
-= Double Post =- Quote:
-= Double Post =- Damn I just tried myself, but if you use <img src=""> you can't send the png header anymore which means you can't hotlink the image. The only other way I know to display and image is the Imagepng function which only works on created pngs, which is a big problem
Last edited by PopeOfDope; 01-21-2007 at 07:41 AM.. Reason: Automerged Doublepost |
|
|
|
|
|
|
#5 |
![]() Enter Custom Title
|
Haha Pope I almost have it.
![]() Here's the code: PHP Code:
"Sig1_box.png" is the png with and mp3 in it. "dummy.png" is a 5x5 png file just so "$Readbase" doesn't give an error to to the fact that "sig_output2.png" doesn't have a size. -= Double Post =- Looks like the last part is proving a problem too. ![]() If we can't solve this I can just let the user refresh the song by clicking my sig then refreshing the page. Last edited by Chathurga; 01-21-2007 at 08:36 AM.. Reason: Automerged Doublepost |
|
|
|
|
|
#6 | |
![]() |
Quote:
Your second image is just a direct link to result.png. EDIT: just to clarify, add this at the end of the code you posted above. PHP Code:
|
|
|
|
|
![]() |
| Tags |
| embedded , image , mp3 , php , problem , random , sig |
| Thread Tools | |
|
|