openning jpeg


#1

hello,

I have strange problem:

  • i try to open or save jpeg file and I get the error
  • the same jpeg and the same code works ok on developer machine, jpeg opens using the same code
  • problem occures only on production machine
  • jpeg opens when I try open it clicking twice on it on production machine
    My code looks that:

Using imageStream As New MemoryStream(currentMhtxAttachment.AttachmentBytes)

                                    Dim exceptionOccurs as Boolean = False
                                Try
                                    Using img As New Bitmap(imageStream)
                                        context.Response.ContentType = currentMhtxAttachment.ContentType
                                        img.Save(context.Response.OutputStream, Imaging.ImageFormat.Jpeg)
                                        context.Response.Flush()
                                    End Using
                                Catch ex As Exception
                                    exceptionOccurs = true
                                    Log.Write(ex.ToString(), enmLogTypes.LOG_ERROR)
                                End Try
                                If exceptionOccurs Then
                                    dim filePath = String.Empty
                                    Using image As Aspose.Imaging.Image = Aspose.Imaging.Image.Load(imageStream)
                                        Dim pathdir As String = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "DocView")
                                        If Not Directory.Exists(pathdir) Then
                                            Directory.CreateDirectory(pathdir)
                                        End If
                                        Dim filename = Guid.NewGuid().ToString()
                                        filePath = System.IO.Path.Combine(pathdir, filename)
                                        using options as New JpegOptions()
                                            image.Save(filePath, options)
                                        End Using
                                    End Using
                                    Using image as New Bitmap(filePath, false)
                                        context.Response.ContentType = currentMhtxAttachment.ContentType
                                        image.Save(context.Response.OutputStream, Imaging.ImageFormat.Jpeg)
                                        context.Response.End()
                                    End Using
                                End If
                            End Using

in this line:
img.Save(context.Response.OutputStream, Imaging.ImageFormat.Jpeg)
occurs error:

System.Runtime.InteropServices.ExternalException (0x80004005): A generic error occurred in GDI+.
at System.Drawing.Image.Save(Stream stream, ImageCodecInfo encoder, EncoderParameters encoderParams)
at System.Drawing.Image.Save(Stream stream, ImageFormat format)
at ImageHandler.ProcessRequest(HttpContext context)

and

in this line:
Using image As Aspose.Imaging.Image = Aspose.Imaging.Image.Load(imageStream)

occurs this:
Aspose.Imaging.CoreExceptions.ImageLoadException: Image loading failed. —> Aspose.Imaging.CoreExceptions.ImageLoadException: Cannot open an image. The image file format may be not supported at the moment.
at Aspose.Imaging.Image.�(StreamContainer �, LoadOptions �)
— End of inner exception stack trace —
at Aspose.Imaging.Image.�(StreamContainer �, LoadOptions �)
at Aspose.Imaging.Image.Load(Stream stream, LoadOptions loadOptions)
at ImageHandler.ProcessRequest(HttpContext context)

Could you help me what is wrong on the production machine?
received_918975251775069_1.jpeg (674.8 KB)


#2

@lukasz.rojek,

I have observed the stack trace shared by you. Can you please share which version of Aspose.Imaging you are using on your end. If you are using older version, please try using latest version on your end. Please also share the development and product environment Operating System details.


#3

Aspose.Imaging for .NET 18.4.0.0

prod.PNG (7.5 KB)
dev.PNG (11.0 KB)


#4

@lukasz.rojek,

Can you please try to use Aspose.Imaging latest version 19.7 on your end. You may download latest version from this link.


#5

when i used this new dll that error occurs:

System.InvalidOperationException: The subscription included in this license allows free upgrades until 27 Apr 2019, but this version of the product was released on 01 Jul 2019. Please renew the subscription or use a previous version of the product.
w .(Object )
w .()
w .()
w .(Object )
w . ()
w .(Object , UInt32 )
w .()
w . ()
w .()
w .(Object )
w . ()
w .(Object , UInt32 )
w .()
w .(Object[] , Type[] , Type[] , Object[] )
w .(Stream , Int32 , Object[] , Type[] , Type[] , Object[] )
w .(Int32 , Type[] , Type[] , Boolean )
w . ( )
w .()
w .()
w .(Object )
w . ()
w .(Object , UInt32 )
w .()
w . ()
w .()
w .(Object )
w . ()
w .(Object , UInt32 )
w .()
w .(Object[] , Type[] , Type[] , Object[] )
w Aspose.Imaging.License.SetLicense(String licenseName)
w ImageHandler.ProcessRequest(HttpContext context)


#6

@lukasz.rojek,

The exception that you have shared means that your license file is not valid for the version you are trying to access. You may try loading without license file in your application or get a temporary license to verify the file on your end. If the latest version does not exhibit issue then you may need to renew your subscription to use latest version.


#7

@lukasz.rojek,

I have also created a working sample project based on shared sample code of older version. I have used code w.r.t Aspose.Imaging for .NET 19.7 on my end and suggest you to please try the attached project on your end and share feedback.

ImagingTest.zip (692.9 KB)