Hi I am developing small school app using angular.js and php that captures images from canvas and then stores it in mySql db.
你好,我正在开发一个使用角的小型学校应用。js和php捕捉画布上的图像,然后将其存储在mySql db中。
The images are stored image/png
;base64 string
.
图像存储为图像/png;base64字符串。
My problem is that when I load these images (300 images of 11.2Kb) it takes lot of time to display it on screen (approx 1 minute for 3Mb HTML).
我的问题是,当我加载这些图片(300张11.2Kb的图片)时,需要花大量的时间在屏幕上显示(大约1分钟,3Mb的HTML)。
Are there any libraries or angular directives that I can use to cache these images when displaying?
在显示这些图像时,我是否可以使用库或角指令来缓存这些图像?
1 个解决方案
#1
2
Well, first of all, storing images in the DB is quite a bad practice. I would recommend you to save images as binary files and store the upload paths.
首先,在DB中存储图像是一种很糟糕的做法。我建议您将图像保存为二进制文件并存储上传路径。
Second, storing large images in base64 would take more memory (base64 images are usually ~33% larger than binaries), and, as claimed here, rendering them might take a significantly more time.
其次,在base64中存储大型图像需要更多的内存(base64图像通常比二进制文件大大约33%),并且,正如这里所述,呈现这些图像可能需要更长的时间。
base64 encoded data may possibly take longer to process than binary data (again, this might be exceptionally painful for mobile devices, which have more limited CPU and memory)
base64编码的数据可能比二进制数据需要更长的时间来处理(同样,对于CPU和内存更有限的移动设备来说,这可能是非常痛苦的)
BTW if I misunderstood you and the bottleneck is reading images from the db, then storing images as files would also help ;)
如果我误解了你,瓶颈就是从数据库读取图像,那么将图像存储为文件也会有所帮助;
#1
2
Well, first of all, storing images in the DB is quite a bad practice. I would recommend you to save images as binary files and store the upload paths.
首先,在DB中存储图像是一种很糟糕的做法。我建议您将图像保存为二进制文件并存储上传路径。
Second, storing large images in base64 would take more memory (base64 images are usually ~33% larger than binaries), and, as claimed here, rendering them might take a significantly more time.
其次,在base64中存储大型图像需要更多的内存(base64图像通常比二进制文件大大约33%),并且,正如这里所述,呈现这些图像可能需要更长的时间。
base64 encoded data may possibly take longer to process than binary data (again, this might be exceptionally painful for mobile devices, which have more limited CPU and memory)
base64编码的数据可能比二进制数据需要更长的时间来处理(同样,对于CPU和内存更有限的移动设备来说,这可能是非常痛苦的)
BTW if I misunderstood you and the bottleneck is reading images from the db, then storing images as files would also help ;)
如果我误解了你,瓶颈就是从数据库读取图像,那么将图像存储为文件也会有所帮助;