简体   繁体   English

从php中的url获取base64编码的png图像

[英]Get base64 encoded png image from url in php

I have picture url from Facebook in jpg format. 我有jpg格式的Facebook图片网址。 But I can manage it in another code only if it is in base64 encoded png format. 但是只有当它采用base64编码的png格式时,我才可以在另一个代码中管理它。 I don't want to rewrite entire module. 我不想重写整个模块。

I have tried everything I found on Internet and nothing works. 我已经尝试过我在互联网上找到的所有内容,但没有任

The closest I solve this is 我最接近解决的是

base64_encode(imagepng(imagecreatefromstring(file_get_contents($url))));

If you have some ideas I would like to hear them. 如果你有一些想法我想听听。

  1. get image, file_get_contents('image.jpg'); get image,file_get_contents('image.jpg');
  2. convert to png: Convert JPG/GIF image to PNG in PHP? 转换为png: 在PHP中将JPG / GIF图像转换为PNG?
  3. do base 64: http://php.net/manual/en/function.base64-encode.php 基地64: http//php.net/manual/en/function.base64-encode.php

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM