Jump to content

Recommended Posts

hi guys first post, cool forums,

 

I am trying to read the binary behind a bitmap image

and I dont know the best way about going about it, I am trying to read to examine the contents of the bitmap, cause the binary is going to be stored in a db, and then exported back in bitmap format

 

any suggestions would greatly help, thanks in advance

<?php

$filename = "file";

$handle = fopen($filename, "rb");

set_magic_quotes_runtime(true);

$contents = fread($handle, 128);

 

fclose($handle);

print_r(unpack("A*",$contents));

 

?>

 

outputs:

Array ( [1] => BM�\0\0\0\0\06\0\0\0(\0\0\0,\0\0,\0\0\0\0\0\0\0\0�\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0�d*�]$�`\'�d*�]$�`\'�d*�]$�`\'�d*�]$�`\'�d*�]$�`\'�d*�]$�`\'�d*�]$�`\'�d*�]$�`\'�d )

 

first 4 bytes are supposed to the size of an image thats pretty much all i know, but once i get the output correct, I can move file pointer around to read and write different thing

Link to comment
https://forums.phpfreaks.com/topic/164278-php-read-binary-from-bitmap/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.