A generic error occurred in GDI+, JPEG Image to MemoryStream

前端 未结 30 1828
再見小時候
再見小時候 2020-11-22 06:47

This seems to be a bit of an infamous error all over the web. So much so that I have been unable to find an answer to my problem as my scenario doesn\'t fit. An exception ge

30条回答
  •  不知归路
    2020-11-22 07:14

    I notice that your "jpeg" case is actually:

                default:
                    format = ImageFormat.Jpeg;
                    break;
    

    Are you sure that the format is jpeg and not something else?

    I'd try:

                case "image/jpg": // or "image/jpeg" !
                    format = ImageFormat.Jpeg;
                    break;
    

    Or check what imageToConvert.MimeType() is actually returning.

    UPDATE

    Is there any other initialisation you need to do to the MemoryStream object?

提交回复
热议问题