Memory consumption in Magick.NET

回眸只為那壹抹淺笑 提交于 2019-12-02 07:58:45

问题


I have the following lines of code in a function. which reads the image from Amazon S3. Image size which i am reading is of 1.37 MB where as when i ran the profiler it says read function in image magick library takes 5.6 mb which is very high. Can anyone explain this behaviour? I am attaching the snapshot of my profiler as well as code.

 AmazonS3 client = Amazon.AWSClientFactory.CreateAmazonS3Client(
                         accessKey,
                         secretKey
                        );

                GetObjectRequest request = new GetObjectRequest
                {
                    BucketName = bucketName,
                    Key = keyName
                };

                var response = client.GetObject(request);                
                MagickImage imgStream = new MagickImage(response.ResponseStream);


回答1:


Your image size on disk is not important for the size of the image in memory. The amount of memory that is necessary is related to the dimensions (width/height) of your image. When the image is loaded the raw data is 'converted' to pixel data. For each channel Magick.NET will use either 8 or 16 bit per pixel (Q8/Q16). So when you have an image that is 4 channels (RGBA) and you are using the Q16 version of Magick.NET you will use 64-bits per pixel. For an image of 1920x1080 you will need 1920*1080*64 = 132710400 bits, and that is around 16.5 Megabytes. The size on disk will be smaller most of the times because most image formats compress the pixel data when they save it to disk.



来源:https://stackoverflow.com/questions/34737302/memory-consumption-in-magick-net

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!