Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
What's wrong with CRC32
Message
De
07/01/2014 14:17:52
 
 
À
07/01/2014 03:45:41
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01591437
Message ID:
01591460
Vues:
56
>That sounds familiar, but I cannot put my finger on the exact item. Must have encountered it when we added linux-based NAS in our environment, but as further problems did not materialize set not up permanent store in grey matter ;-)

I have eliminated the NAS out of the loop. The CRC32 is responding ok on my Windows 7, Windows Server 2003 and Windows Server 2008, no matter if this is a local drive, a map drive or a NAS drive.

After more investigations, this seems to be related to when I resize the file. The resizing does not end up with the same file size as before, thus impact the result of the CRC32.

Under Windows 7 and Windows Server 2008, with .NET Framework 4.0 and .NET Framework 4.5, in their respective order, I obtain a resize file size identical. However, under Windows Server 2003 with .NET Framework 4.0, I obtain a different file size when executing the same. This is the same as the old environment. So, because the old environment used to resize the file, a JPG file, to a specific size, we ended up using that to process the CRC32. However, I just found out that under Windows 7 and in the new environment, the JPG resized file is no longer the same.

This is the code I am using the resize a JPG file:
    Public Function ImageResize() As Boolean
        Dim lnRatio As Double = 0
        Dim lnRatioImage As Double = 0
        Dim loFinalImage As Bitmap = Nothing
        Dim loGraphics As System.Drawing.Graphics
        Dim loImage As System.Drawing.Bitmap

        lImageHasBeenPreserved = False

        ' If the image is already with the proper dimensions
        If nWidth = oImage.Width And nHeight = oImage.Height Then
            lImageHasBeenPreserved = True
            Return True
        End If

        loImage = New System.Drawing.Bitmap(nWidth, nHeight, oImage.PixelFormat)

        ' Make sure we can resize
        If loImage.PixelFormat = Drawing.Imaging.PixelFormat.Format1bppIndexed Or _
            loImage.PixelFormat = Drawing.Imaging.PixelFormat.Format4bppIndexed Or _
            loImage.PixelFormat = Drawing.Imaging.PixelFormat.Format8bppIndexed Or _
            loImage.PixelFormat = Drawing.Imaging.PixelFormat.Undefined Or _
            loImage.PixelFormat = Drawing.Imaging.PixelFormat.DontCare Or _
            loImage.PixelFormat = Drawing.Imaging.PixelFormat.Format16bppArgb1555 Or _
            loImage.PixelFormat = Drawing.Imaging.PixelFormat.Format16bppGrayScale Then
            cMessage = cPixelFormatNotSupported
            nError = 1
            Return False
        End If

        lnRatio = nWidth / nHeight
        lnRatioImage = oImage.Width / oImage.Height

        If lnRatioImage < lnRatio Then
            nCropWidth = oImage.Width
            nCropHeight = oImage.Width / lnRatio
        Else
            nCropWidth = oImage.Height * lnRatio
            nCropHeight = oImage.Height
        End If

        ' Crop first
        If Not Crop() Then
            Return False
        End If

        ' Create the placeholder
        loFinalImage = New Bitmap(nWidth, nHeight)

        ' Assign the placerholder into the graphic converter
        loGraphics = System.Drawing.Graphics.FromImage(loFinalImage)

        ' Set the parameters
        loGraphics.SmoothingMode = Drawing.Drawing2D.SmoothingMode.HighQuality
        loGraphics.InterpolationMode = Drawing.Drawing2D.InterpolationMode.HighQualityBicubic
        loGraphics.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality
        loGraphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality

        ' Resize the image
        loGraphics.DrawImage(oImage, 0, 0, nWidth, nHeight)

        ' Release the image
        loGraphics.Dispose()

        ' The oImage property can now be assigned to the resized version
        oImage = loFinalImage

        Return True
    End Function
That code did not change. It is the same since two years.

It is still not clear why the Windows Server 2003 environment, the old one, used to resize to a much bigger size when doing the same process on the same file.

Both Windows 7 and Windows Server 2003 have .NET Framework 4.0 installed and they resize the same file under a different file size. And, Windows 7 with .NET Framework 4.0 and Windows Server 2008 with .NET Framework 4.5 resize the same file with the same file size.

Anyone would know something about this mystery?

We have 50 million files which have been generated under Windows Server 2003 and now we cannot find duplicates because of this resizing issue which is not generating the same file size. Of course, if no solution would be found, we would have to generate a new CRC32 for all existing records. But, this is a very weird situation and I would rather find the cause of this.
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform