• php将图片链接转换为base64编码文件流


        /**
             * 图片链接转换为 base64 文件流
             * @param $imgUrl
             * @return string
             */
            function img_url_to_base64($imgUrl)
            {
                $imageInfo = getimagesize($imgUrl);
                return 'data:' . $imageInfo['mime'] . ';base64,' . chunk_split(base64_encode(file_get_contents($imgUrl)));
            }
    {
        "code": 0,
        "message": "操作成功",
        "data": {
            "img_base64": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAcUAAAHFAQAAAACrut8pAAAAAmJLR0QAAd2KE6QAAAAJcEhZcwAA
    AEgAAABIAEbJaz4AAAAJdnBBZwAAAcUAAAHFAEXPcIYAAAOeSURBVHhe7ZxNbiIxEIU7QgrL3CBc
    gQNE4lrsmqNxlByhlywQHr/6cdOI/pExE7m63iYU9hdNntqvbCdMEzJ1aR7fWSon5+TknCLZNUkf
    j8NDXfuZTVuYvGzCrem24Yr6sjl/x+J0cLJZHTmmkmQrI+dZcievurLk75c6dPrh73Sm+dEuJ1dF
    TqgoSYtgu4jkJVWUjD4E/Otv6FQoIBScCU6uhpyUIVJNiUsQXfD3SxfvrENO2iInZYgkU44bmghT
    +n3fz4eTayInVZSUkSUkqyiJTIgOJVOoJUpAOLkmclIlyaRZsldBkhxqw3knpgwKJ1dETqocmaly
    JLqgvh50QbLrXk7aJperOpJWvjS+gNusGAPxON/hypY2gXcB0U9z0h6ZqepI/OhQf4F12egwO/Qd
    R3gTeOxvdp00R2aqShK7uz4TjuwQmXIn6o8cEMFJyCCZoQrJ+KNfZOUf2CHygR3SEcoEMTJlgpO2
    yCxVR17ZB25vB347OkR2RVM0IOCd2gU5aY7MVHUkOSSmBAQEm0IrnwNCYwCZQJJMcNIWmanqSHUI
    PgTcZsEUdMEAu4YjLWZ2FB1OmiMzVSXJMUAihwJ8IO+iKewQjbSYQYWTNskMVUjyhm6npiQhBvgV
    jdzt+66DM5KTVsgsVUfCFMTArdHDTYtNoJhyN6IFbwKdNEdmqkrySa8LOM9wJsAUMjJFh5NWyQxV
    SNJi5/bGb6Ze148gBhAdZCSiw0mDZJaqJDkGuL1RQOxQSwzwTM0EsuvgpFEyQ9WRWPnJBwQECjQ+
    +EAxgMYXixgQLWZwS3TSHJmp6kgsdo4B9YFMocZHpvQtMX7hkYOTBslMVUf2DoVh44MPVCAgyKE4
    LQzSxElLZKb+B9nJh0jokB1eJMUhbXzaErVgbHvaC/nZPKaJk0bIheqELPL0LZR8rPANpKx8bnxQ
    2vftE9k9vb910hY5rrlnaFxPSF0EzfTnBTt8dHz3HlIdYh+QFskhITu9v3XSNDmm+WdoTE/JVorz
    DIkvbyCvbEqUOARRf9wL+SneOWmbHJdMG32GxvWcXPL/fuiSKk/CobjvoxigCbELAtsmEvs+J+2T
    41Jy7BkaVz75qHJk71Dg2yy1S489qT86aZtcrrpJOIQYuPHKV1P4OH8/4qRxcrleJaX4M5JOOuyD
    BAQV7FDLxx4n10Au1Ytk0t+QdJt1TH+GRJkQ1dEvKQZ2OWmbXK6XyEw5OScn5/QC+Q80ME27gJ1j
    9gAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAyMC0wNi0xNlQxNDo1MjowOCswODowMJs4XlEAAAAldEVY
    dGRhdGU6bW9kaWZ5ADIwMjAtMDYtMTZUMTQ6NTI6MDgrMDg6MDDqZebtAAAAAElFTkSuQmCC
    "
        }
    }

    Enjoy it !

  • 相关阅读:
    excel中如何筛选出同一列有重复的数据
    JTextFile换行
    DOM事件对象用法
    js事件监听
    webstorm 破解方法
    vux使用
    vue动态添加当前事件下的class
    subline3 如何设置es6高亮
    vueJS+ES6开发移动端APP实战项目笔记
    css命名规范和书写规范
  • 原文地址:https://www.cnblogs.com/daizhongxing/p/13140965.html
Copyright © 2020-2023  润新知