douweng3564 2014-11-08 07:44
浏览 33
已采纳

PHP Alter Base64图像编码

I am developing an application and for that I need to generate multiple copies of same image with unique base 64 encoding.

However I am not sure that if I add a random string like "aasasa" in between my image code whether it will corrupt image or it will display properly?

Is there any way to achieve this?

    $imageDataEncoded = base64_encode(file_get_contents($_FILES["fileToUpload"]["tmp_name"]));

     $imageData = base64_decode($imageDataEncoded);
     $imageData="asasasas".$imageData;
     $source = imagecreatefromstring($imageData);

Thanks Ahmar

  • 写回答

1条回答 默认 最新

  • duankanjian4642 2014-11-08 08:00
    关注

    It's not entirely obvious why you would want to do this (maybe there is a better way to achieve what you're after). Anyways, I would try and change the image metadata. By changing the metadata you are "not changing" the image itself.

    Further reading material:

    http://php.net/manual/en/book.exif.php

    http://php.net/manual/en/function.iptcembed.php

    http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/EXIF.html

    This can be achieved by using a EXIF library, but be aware that these changes are obviously way more performance intensive and can slow down your load time significantly, especially if you do this on a lot of pages.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题