>I'm using a Zebra label printer in an application I have and in order to >display an image on the label, according to the ZPL II printer language, >any image must be converted to HEX code. Does anyone hvae a code snippet or >know of a free utility that will take a graphic image (BMP, GIF, JPG, >etc...) and convert it to HEX values?
Something not unlike this may work... <?php $image = 'sample.bmp'; $file = fopen($image, 'r') or die("Could not open $image"); while ($file && !feof($file)){ $chunk = fread($file, 1000000); # You can affect performance altering this number. YMMV. # This loop will be dog-slow, almost for sure... # You could snag two or three bytes and shift/add them, # but at 4 bytes, you violate the 7fffffff limit of dechex... # You could maybe write a better dechex that would accept multiple bytes # and use substr... Maybe. for ($byte = 0; $byte < strlen($chunk); $byte++)){ echo dechex(ord($chunk[$byte])); } } ?> -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php