Reputation: 1068
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
Upvotes: 0
Views: 87
Reputation:
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.
Upvotes: 1