Home > Backend Development > PHP Problem > How to convert images into binary streams in php

How to convert images into binary streams in php

藏色散人
Release: 2023-03-08 15:54:01
Original
3675 people have browsed it

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.

How to convert images into binary streams in php

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);
Copy after login

[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!

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template