Note that there are some explanatory texts on larger screens.

plurals
  1. POc# Image scaling quality different between dev and production environment
    primarykey
    data
    text
    <p>i have created a function that resizes and crops a picture and then saves the resulting image file. In my development environment it works just great, but on production the resulting image is "grainy". You can see the different quality here <a href="http://test.powersport.it/canc2.aspx" rel="nofollow">http://test.powersport.it/canc2.aspx</a></p> <p>Here is the code that generates the resized and cropped image</p> <pre><code> // width: width of cropped img - height: height of cropped img System.Drawing.Bitmap thumbnail = new Bitmap(width, height); // image: original System.Drawing.Image containing full size img thumbnail.SetResolution(image.HorizontalResolution, image.VerticalResolution); // size[0]: width of resized img - size[1]: height of resized image System.Drawing.Image mini = new Bitmap(image, size[0], size[1]); System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(thumbnail); g.InterpolationMode = InterpolationMode.HighQualityBicubic; g.SmoothingMode = SmoothingMode.HighQuality; g.PixelOffsetMode = PixelOffsetMode.HighQuality; g.CompositingQuality = CompositingQuality.HighQuality; g.DrawImage(mini, ((width - size[0]) / 2), ((height - size[1]) / 2), size[0], size[1]); EncoderParameters encoderParameters; encoderParameters = new EncoderParameters(1); ImageCodecInfo[] info = ImageCodecInfo.GetImageEncoders(); // img: original file name switch (Path.GetExtension(img).ToLower()) { case ".png": // info[4] thumbnail.Save(dest, System.Drawing.Imaging.ImageFormat.Png); break; case ".bmp": // info[0] thumbnail.Save(dest, System.Drawing.Imaging.ImageFormat.Bmp); break; case ".tiff": // info[3] encoderParameters.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.Compression, (long)EncoderValue.CompressionLZW); thumbnail.Save(dest, info[3], encoderParameters); break; case ".tif": // info[3] encoderParameters.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.Compression, (long)EncoderValue.CompressionLZW); thumbnail.Save(dest, info[3], encoderParameters); break; default: //jpeg info[1] encoderParameters.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, compression); thumbnail.Save(dest, info[1], encoderParameters); break; } </code></pre> <p>Any help is appreciated. Thanks.</p> <p><strong>UPDATE</strong>: i've tried with PNG, BMP and TIFF but they have the same problem</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload