Identyczny kod powodujący niespójną jakość obrazu na różnych serwerach

Wykonaj następujące dwa zdjęcia:

Wersja Dev - IIS7 Windows 7 Pro 64-bitowa maszyna

Wersja na żywo - 64-bitowy komputer z systemem Windows Server 2008 IIS7

Zwróć uwagę, że wersja na żywo jest „pixelly” i wygląda na niską jakość, jednak wersja Dev jest gładka, wygładzona i wygląda dobrze. Oba są generowane przez identyczny kod:

' Settings
Dim MaxHeight As Integer = 140
Dim MaxWidth As Integer = 140
Dim WorkingFolderPath As String = "\\server\share\bla\"
Dim AllowedFileExtensions As New ArrayList
AllowedFileExtensions.Add(".jpg")
AllowedFileExtensions.Add(".jpeg")

' Select an image to use from the WorkingFolder
Dim ImageFileName As String = ""
Dim WorkingFolder As New IO.DirectoryInfo(WorkingFolderPath)
Dim SourceImages As IO.FileInfo() = WorkingFolder.GetFiles()

For Each SourceImage As IO.FileInfo In SourceImages
    If AllowedFileExtensions.Contains(SourceImage.Extension.ToLower) = True Then
        ImageFileName = SourceImage.Name
    End If
Next

' Determine path to selected image (if no image was found use a placeholder)
Dim PhysicalPath As String = ""
If ImageFileName = "" Then
    ' No Image was found, use the filler image
    PhysicalPath = Server.MapPath("ProductOfTheMonthMissing.jpg")
Else
    ' An Image was found, Redirect to it / build path for Thumnailing
    If Request.QueryString("FullSize") = "true" Then
        Response.Redirect("../share/bla/" & ImageFileName)
    Else
        PhysicalPath = WorkingFolderPath & ImageFileName
    End If
End If

' Load image and output in binary (resizing if necessary)
Using ProductImage As System.Drawing.Image = System.Drawing.Image.FromFile(PhysicalPath)
    Dim newWidth As Integer = ProductImage.Width
    Dim newHeight As Integer = ProductImage.Height

    ' Check if selected size is too big, if so, determine new size
    If ProductImage.Width > MaxWidth Or ProductImage.Height > MaxHeight Then
        Dim ratioX As Double = CDbl(MaxWidth) / ProductImage.Width
        Dim ratioY As Double = CDbl(MaxHeight) / ProductImage.Height
        Dim ratio As Double = Math.Min(ratioX, ratioY)

        newWidth = CInt(ProductImage.Width * ratio)
        newHeight = CInt(ProductImage.Height * ratio)
    End If

    ' Create a new bitmap from the image with new size
    Dim Codecs As ImageCodecInfo() = ImageCodecInfo.GetImageEncoders()
    Dim CodecInfo As ImageCodecInfo = Nothing
    Dim ProductOfTheMonth As New Bitmap(ProductImage, newWidth, newHeight)
    Dim ReSizer As Graphics = Graphics.FromImage(ProductOfTheMonth)

    ReSizer.InterpolationMode = InterpolationMode.HighQualityBicubic
    ReSizer.SmoothingMode = SmoothingMode.HighQuality
    ReSizer.PixelOffsetMode = PixelOffsetMode.HighQuality
    ReSizer.CompositingQuality = CompositingQuality.HighQuality

    ' Ensure the encoder uses the best quality settings
    Dim EncoderParams As New EncoderParameters(3)
    EncoderParams.Param(0) = New EncoderParameter(System.Drawing.Imaging.Encoder.Quality, 100L)
    EncoderParams.Param(1) = New EncoderParameter(System.Drawing.Imaging.Encoder.ScanMethod, CInt(EncoderValue.ScanMethodInterlaced))
    EncoderParams.Param(2) = New EncoderParameter(System.Drawing.Imaging.Encoder.RenderMethod, CInt(EncoderValue.RenderProgressive))

    ' Set jpeg as the output codec
    For Each Codec As ImageCodecInfo In Codecs
        If Codec.MimeType = "image/jpeg" Then
            CodecInfo = Codec
        End If
    Next

    ' Ready a memory stream and byte array
    Dim MemStream As New MemoryStream()
    Dim bmpBytes As Byte()

    ' Save the image the the memory stream & prep ContentType for HTTP reasponse
    Response.ContentType = "image/jpeg"
    ProductOfTheMonth.Save(MemStream, CodecInfo, EncoderParams)

    ' Flush memory stream into byte array & flush to browser
    bmpBytes = MemStream.GetBuffer()
    Response.BinaryWrite(bmpBytes)

    ' Cleanup
    ProductOfTheMonth.Dispose()
    MemStream.Close()
    ProductImage.Dispose()
End Using

Jaka jest przyczyna tego i jak rozwiązać ten problem? Prawdopodobnie jest to problem GD na serwerze internetowym na żywo - ale nie mam pojęcia co - starałem się być jak najdokładniejszy przy ustawianiu ustawień graficznych i kodeków, ale nadal jest inny?

Edytować: Obraz źródłowy jest również identyczny w obu przykładach (znajduje się na centralnym udziale unc) - kopia obrazu źródłowegotutaj

questionAnswers(3)

yourAnswerToTheQuestion