Serializing Image Class [SOLVED]
Posted: 2012-08-21T08:19:51-07:00
Hi,
I am working on a program that has a large number of base images and it then dynamically generates images on top of those images. The base images are 1900x1900 png files and I have found that it takes about 250ms to load them into imagemagick and only about 10ms to read from the disk. Because of this extra time I am wondering if there is a way to serialize the Image class so that I can write it to a file and load it at a faster rate than trying to load a png file. I have already implemented writing to a character string of RGBA data and putting that in a file for future use and that reduces load time to about 80ms on average when reading from a memory based partition. Due to the large number of images I cannot keep them all in memory but reading from the hard disk does not seem to be the slow point in the process since it reads the entire file into a Blob takes 10ms but reading the Blob into an Image takes 200ms. Ideally I would serialize the entire class so that it can quickly load from disk without having to reparse an image file but I do not see any way to do that. Is there something similar to this already available or will I have to code it myself? I do need alpha/opacity channels so I cannot save to a format without support for that.
I compiled ImageMagick-6.7.8-10 from source.
I am working on a program that has a large number of base images and it then dynamically generates images on top of those images. The base images are 1900x1900 png files and I have found that it takes about 250ms to load them into imagemagick and only about 10ms to read from the disk. Because of this extra time I am wondering if there is a way to serialize the Image class so that I can write it to a file and load it at a faster rate than trying to load a png file. I have already implemented writing to a character string of RGBA data and putting that in a file for future use and that reduces load time to about 80ms on average when reading from a memory based partition. Due to the large number of images I cannot keep them all in memory but reading from the hard disk does not seem to be the slow point in the process since it reads the entire file into a Blob takes 10ms but reading the Blob into an Image takes 200ms. Ideally I would serialize the entire class so that it can quickly load from disk without having to reparse an image file but I do not see any way to do that. Is there something similar to this already available or will I have to code it myself? I do need alpha/opacity channels so I cannot save to a format without support for that.
I compiled ImageMagick-6.7.8-10 from source.