locked
about resizing image with high quality RRS feed

  • Question

  • User2089495229 posted

    hi,

    i use this code for resize my images. but this images quality is bad. 

    when i resized with photoshop, images quality is better than my codes.

    sample images as a bottom of my message. 

    how can i resize with asp.net and photoshop quality ?

    thanks.

    1. Public Function ResizeImage(ByVal streamImage As Stream, ByVal maxWidth As IntegerByVal maxHeight As IntegerAs Bitmap  
    2.         Dim originalImage As New Bitmap(streamImage)  
    3.         Dim newWidth As Integer = originalImage.Width  
    4.         Dim newHeight As Integer = originalImage.Height  
    5.         Dim aspectRatio As Double = CDbl(originalImage.Width) / CDbl(originalImage.Height)  
    6.   
    7.         If aspectRatio <= 1 And newHeight > maxHeight Then ' gorsel dikey veya kare ise  
    8.             newHeight = maxHeight  
    9.             newWidth = CInt(Math.Round(maxHeight * originalImage.Width / originalImage.Height))  
    10.         ElseIf aspectRatio > 1 And newWidth > maxWidth Then ' gorsel yatay ise  
    11.             newWidth = maxWidth  
    12.             newHeight = CInt(Math.Round(maxWidth * originalImage.Height / originalImage.Width))  
    13.         End If  
    14.   
    15.         Dim newImage As New Bitmap(originalImage, newWidth, newHeight)  
    16.   
    17.         Dim g As Graphics = Graphics.FromImage(newImage)  
    18.         g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBilinear  
    19.         g.DrawImage(originalImage, 0, 0, newImage.Width, newImage.Height)  
    20.   
    21.         g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality  
    22.         g.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality  
    23.         g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality  
    24.   
    25.         originalImage.Dispose()  
    26.         Return newImage  
    27.     End Function  

     

    Saturday, August 29, 2009 7:45 AM

Answers

  • User581622694 posted

    go through following url

    http://www.codeproject.com/KB/web-image/pnguploader.aspx

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, August 29, 2009 8:38 AM
  • User1506406490 posted

     Hi good day

    its nice that u r trying so many things.I had seen u code ,if u think it not working up to u's expectation,then u can use photoshop,as all are using that design tools only[considering abt me].As what i do many of time depending on my images properties[heights,widhts,size,area etc] for making  them workable to me,i got one software for that namely "Photosizer"  that s/w support me lot,it takes very less time for resizing of big images;through it u can givew u desired height,width,even size etc & accordingly that s/w resize all, even if u want different size of same images then also u can do that.So i prefer u to get that s/w or otherwise the photoshop is there or else u can go for the online support.Remember that s/w name.

    Good luck 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, August 29, 2009 9:10 AM

All replies

  • User581622694 posted

    go through following url

    http://www.codeproject.com/KB/web-image/pnguploader.aspx

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, August 29, 2009 8:38 AM
  • User1506406490 posted

     Hi good day

    its nice that u r trying so many things.I had seen u code ,if u think it not working up to u's expectation,then u can use photoshop,as all are using that design tools only[considering abt me].As what i do many of time depending on my images properties[heights,widhts,size,area etc] for making  them workable to me,i got one software for that namely "Photosizer"  that s/w support me lot,it takes very less time for resizing of big images;through it u can givew u desired height,width,even size etc & accordingly that s/w resize all, even if u want different size of same images then also u can do that.So i prefer u to get that s/w or otherwise the photoshop is there or else u can go for the online support.Remember that s/w name.

    Good luck 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, August 29, 2009 9:10 AM