abramenal / cypress-file-upload

File upload testing made easy
https://npm.im/cypress-file-upload
MIT License
496 stars 89 forks source link

[Bug] “Parameter is not valid” asp.net bitmap, upload image using cypress #325

Closed AbrahemAlhofe closed 2 years ago

AbrahemAlhofe commented 2 years ago

I want to test file input by uploading image with cypress-file-upload but asp.net Bitmap class throw exception error Parameter is not valid when it gets the image by InputStream

Cypress spec command

cy.get(".v-select-image#photo-url-ar .v-select-image__input")
   .attachFile("image-1.jpg")

Asp.net class that handling image compressing process

Public Sub SaveAs(ImagePath As String, ImageWidth As Integer, ImageHeight As Integer)

        Try

            Dim originalBitmap As Bitmap = New Bitmap(OriginalImage.InputStream)
            Dim originalWidth As Integer = originalBitmap.Width
            Dim originalHeight As Integer = originalBitmap.Height

            Dim bitMAP1 = New Bitmap(originalBitmap, originalWidth, originalHeight)
            Dim graph = Graphics.FromImage(bitMAP1)

            graph.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality
            graph.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality
            graph.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic

            Dim imageRectangle = New Rectangle(0, 0, ImageWidth, ImageHeight)
            graph.DrawImage(originalBitmap, imageRectangle)
            bitMAP1.SetResolution(300, 300)
            bitMAP1.Save(ImagePath, System.Drawing.Imaging.ImageFormat.Jpeg)
            graph.Dispose()
            bitMAP1.Dispose()

        Catch __unusedException1__ As Exception
            Throw
        End Try

End Sub
abramenal commented 2 years ago

If this is still relevant, feel free to reopen and tell more about the exception details.