简体   繁体   中英

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.

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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