Jump to content

php read binary from bitmap


Guest

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.