相关疑难解决方法(0)

System.Drawing.Image.FromFile()上的Out of Memory异常

我有一个图像上传器和裁剪器,它创建缩略图,我偶尔会在以下行中获得Out Of Memory异常:

Dim bm As Bitmap = System.Drawing.Image.FromFile(imageFile)
Run Code Online (Sandbox Code Playgroud)

错误的发生是微小的,非常罕见,但我总是想知道可能导致它的原因.imageFile变量只是一个Server.MapPath到图像的路径.

我很好奇,如果有人以前遇到过这个问题,他们是否有任何想法可能导致它?这可能是图像的大小吗?

我可以在必要时发布代码以及我所拥有的任何支持信息,但是我很乐意听到人们对此的看法.

asp.net image bitmap

41
推荐指数
3
解决办法
7万
查看次数

使用C#创建缩略图图像

@functions{

    public void GetThumbnailView(string originalImagePath, int height, int width)
    {
        //Consider Image is stored at path like "ProductImage\\Product1.jpg"

        //Now we have created one another folder ProductThumbnail to store thumbnail image of product.
        //So let name of image be same, just change the FolderName while storing image.
        string thumbnailImagePath = originalImagePath;
        originalImagePath = originalImagePath.Replace("thumb_", "");
        //If thumbnail Image is not available, generate it.
        if (!System.IO.File.Exists(Server.MapPath(thumbnailImagePath)))
        {
            System.Drawing.Image imThumbnailImage; 
            System.Drawing.Image OriginalImage = System.Drawing.Image.FromFile(Server.MapPath(originalImagePath));

            double originalWidth = OriginalImage.Width;
            double originalHeight = OriginalImage.Height;

            double …
Run Code Online (Sandbox Code Playgroud)

c# jpeg gdi+ razor asp.net-mvc-3

5
推荐指数
1
解决办法
5410
查看次数

服务器上的GetThumbnailImage中的C#内存不足异常

我正在运行以下代码,以便在用户向我们发送图像时创建缩略图:

public int AddThumbnail(byte[] originalImage, File parentFile)
    {
        File tnFile = null;
        try
        {
            System.Drawing.Image image;
            using (System.IO.MemoryStream memoryStream = new System.IO.MemoryStream(originalImage))
            {
                image = System.Drawing.Image.FromStream(memoryStream);
            }
            Log.Write("Original image width of [" + image.Width.ToString() + "] and height of [" + image.Height.ToString() + "]");
            //dimensions need to be changeable
            double factor = (double)m_thumbnailWidth / (double)image.Width;

            int thHeight = (int)(image.Height * factor);
            byte[] tnData = null;
            Log.Write("Thumbnail width of [" + m_thumbnailWidth.ToString() + "] and height of [" + thHeight + …
Run Code Online (Sandbox Code Playgroud)

c# iis image server

3
推荐指数
2
解决办法
2032
查看次数

标签 统计

c# ×2

image ×2

asp.net ×1

asp.net-mvc-3 ×1

bitmap ×1

gdi+ ×1

iis ×1

jpeg ×1

razor ×1

server ×1