locked
Logo on Images RRS feed

  • Question

  • User1906504752 posted

    I want to put my logo on uploaded images.  

    I used this code.. But it enlarges the Logo image and the logo is not getting a good qulity.

     

      string imgPathTemp = Server.MapPath(string.Concat("~/upload/temp/", Images[j].ImageName));
                            System.Drawing.Image imgTemp = System.Drawing.Image.FromFile(imgPathTemp);
                            Bitmap bitmapSmall = CreateThumbnail(imgTemp, 80, 60);
                            bitmapSmall.Save(Server.MapPath(string.Concat("~/upload/final/small/", Images[j].ImageName)), System.Drawing.Imaging.ImageFormat.Jpeg);
                            bitmapSmall.Dispose();
    
                            Graphics graphTemp = Graphics.FromImage(imgTemp);
                            System.Drawing.Image imgOverlay = System.Drawing.Image.FromFile(Server.MapPath("~/App_Themes/" + Page.Theme + "/images/videoOverlay.png"));
                            graphTemp.DrawImage(imgOverlay, imgTemp.Width - imgOverlay.Width - 20, imgTemp.Height - imgOverlay.Height);
                            imgTemp.Save(Server.MapPath(string.Concat("~/upload/final/large/", Images[j].ImageName)), System.Drawing.Imaging.ImageFormat.Jpeg);
    
                            graphTemp.Dispose();
                            imgTemp.Dispose();
                            imgOverlay.Dispose();
     
    Sunday, March 8, 2009 7:56 PM

Answers

  • User1677479917 posted

     Hi,

    I have also faced the same problem the reason is :

    Image formats like jpeg may store the thumbnail inside the same file. If we use System.Drawing.Bitmap method GetThumbnailImage, method checks if there’s a thumbnail image stored into the file and, if the thumb is found, it returns that thumbnail version scaled to the width and height you requested. If the thumbnail version of the image is smaller then the size you requested to produce, thats when problem occurs. The thumbnails produced become pixelated as we know stretching an image to a larger once reduces the Image Quality.

    you can try this [it worked for me with little modifications as per my requirement but it will work fine for you i guess..] 

    http://www.webcosmoforums.com/asp/321-create-high-quality-thumbnail-resize-image-dynamically-asp-net-c-code.html

    Src code of it : http://www.cosmocentral.com/2007/10/create-high-quality-thumbnail-resize-image-dynamically-asp-net-c-code/

    Try this and if it works say thanks to "Manik" who has posted this nice article!!

    If any help needed give me a shout ......

    Thank you

    "Dream is a heart of life...So keep it beating...Live your dreams!!"

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, March 9, 2009 12:10 AM