Home >Backend Development >PHP Problem >How to convert images into binary streams in php
php method to convert an image into a binary stream: first create a PHP sample file; then use the "function binaryEncodeImage($img_file){...}" method to convert the image into a binary data stream.
The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer
php image conversion binary data stream
/* 图片转化为二进制数据流 */ function binaryEncodeImage($img_file) { $p_size = filesize($img_file); $img_binary = fread(fopen($img_file, "r"), $p_size); return $img_binary; } /* 二进制数据流存储为图片 */ file_put_contents(图片路径, $data);
[Recommended learning: "PHP Video Tutorial"]
The above is the detailed content of How to convert images into binary streams in php. For more information, please follow other related articles on the PHP Chinese website!