pudge1 Posted August 19, 2009 Share Posted August 19, 2009 I want to convert a .bin Binary File to a .png Image File. Here is my code: <?php $file = 'test.bin'; $fp = fopen($file, "r"); $filestream = fread($fp, filesize($file)); $filestream = base64_decode($filestream); $stream = imagecreatefromstring($filestream); if ($stream !== false) { header("Content-type: image/png"); imagepng($stream); imagedestroy($stream); } else { echo "An error occured."; } ?> I don't have the kind of binary file I want to convert to test it. I am not sure if I am doing it write though in the first place. Can someone tell me if this would convert a binary file to an image by any chance? Link to comment https://forums.phpfreaks.com/topic/170926-php-binary-conversion/ Share on other sites More sharing options...
jjacquay712 Posted August 19, 2009 Share Posted August 19, 2009 Not sure what you mean by a binary file. Link to comment https://forums.phpfreaks.com/topic/170926-php-binary-conversion/#findComment-901527 Share on other sites More sharing options...
MadTechie Posted August 19, 2009 Share Posted August 19, 2009 Firstly a binary file could be almost anything (not limited to an image) the extension .bin is commonly used for CD/DVD images (not pictures but disc images) the fact your using base64_decode would suggest your dealing with a MacBinary archive (which I have only seen on email on Mac OS9 (classic), However by looking at your script it would suggest you have a JPEG, PNG, GIF, WBMP, or GD2 file and are attempting to convert to png if its not one of those formats then your need to give some details Link to comment https://forums.phpfreaks.com/topic/170926-php-binary-conversion/#findComment-901531 Share on other sites More sharing options...
pudge1 Posted August 19, 2009 Author Share Posted August 19, 2009 What I am trying to do is convert a .bin file generated by Super Smash Bros BRAWL that you can put on a SD card but it is in a .bin file. So I need to convert it to a .png. Link to comment https://forums.phpfreaks.com/topic/170926-php-binary-conversion/#findComment-901548 Share on other sites More sharing options...
MadTechie Posted August 19, 2009 Share Posted August 19, 2009 Use SSBB Bin file viewer or maybe attach a file so someone can look at it to write a convertor Link to comment https://forums.phpfreaks.com/topic/170926-php-binary-conversion/#findComment-901695 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.