Firstly, English is not my main language sorry for my grammer :).
What I wanna do?
I wanted to add a front end animated gif submission to my website. Gif also needs to be resized multiple dimensions.
What I did?
After realizing splitting gif to frames and resizing them is an expensive code for PHP(It's about 13 seconds to resize a 3MB 52 frames gif to 2 diffirient dimensions with imagick library); I changed my way and tried to do splitting and resizing job on the browser/client side and convert those resized frames into base64 jpegs and I succeed(frames to array buffer-array buffer to canvas-canvas to base64. Resizing a 3MB 52 frames gif to 2 dimensions taking 2-3 seconds). Now I was sending a lot of base64 data to the server.
Then first thing I look for a library to re-join those frames on server side. (re-joining frames on the server side to prevent any security vulnerabilities, re-joining them will corrupt hack codes in the frames if there is one.)
I found the GifAnim library that performs really good and updated.
All good! 13 seconds server side animated gif resizing went to into 2-3 seconds on the client and 1 second for the server side!
But I started to think "maybe it's better if I send a file object instead of base64 code for frames?" because sending 104 base64 image code to server (52 frames and 2 diffirent dimensions) looked too big for me. Also I have to base64_decode() -> imagecreatefromstring() all of those 104 base 64 image to use them as an image.
Question: Would it be better if I turns base64 into file object and sending file objects instead of base64 image codes to the server?
How good/stable base64_decode() function? Because decoding 100-150 images looked so unnatural to me.
Thanks for your advices!
question from:
https://stackoverflow.com/questions/65911009/sending-a-lot-of-base64-data-to-php-server 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…