简体   繁体   English

PHP Alter Base64图像编码

[英]PHP Alter Base64 Encoding of image

I am developing an application and for that I need to generate multiple copies of same image with unique base 64 encoding. 我正在开发一个应用程序,为此,我需要使用唯一的base 64编码生成同一图像的多个副本。

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? 但是,我不确定如果在图像代码之间添加诸如“ aasasa”之类的随机字符串,它将破坏图像还是将其正确显示?

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 谢谢阿马尔

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/book.exif.php

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

http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/EXIF.html 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. 这可以通过使用EXIF库来实现,但是请注意,这些更改显然会占用更多的性能,并且会显着减慢加载时间,尤其是在很多页面上执行此操作时。

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

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