Possible inventory save Image bug in 7.1  Topic is solved

Discussions relating to plugin development, and the Jiwa API.

Possible inventory save Image bug in 7.1

Postby SBarnes » Mon Jul 23, 2018 5:11 pm

Hi Mike,

in trying to save out an image in 7.1 the error below is produced, the same image works fine in 7.0.175 as do other images that don't work in 7.1, images brought in using the import utility have the same problem.


save image error.jpg
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Possible inventory save Image bug in 7.1

Postby Scott.Pearce » Mon Jul 23, 2018 5:31 pm

Can you please test in 7.1.8.0?

Download from:

ftp://ftp.jiwa.com.au/07.01.08.00/Setup.exe

https://service.jiwa.com.au/browse/DEV-6757 may have sorted it.
Scott Pearce
Senior Analyst/Programmer
Jiwa Financials
User avatar
Scott.Pearce
Senpai
Senpai
 
Posts: 742
Joined: Tue Feb 12, 2008 11:27 am
Location: New South Wales, Australia
Topics Solved: 221

Re: Possible inventory save Image bug in 7.1

Postby Mike.Sheen » Mon Jul 23, 2018 5:43 pm

Scott.Pearce wrote:https://service.jiwa.com.au/browse/DEV-6757 may have sorted it.


Oh, I doubt that issue is related - that was a very specific bug related to icon maintenance, not images. But I do recall an issue similar to what Stuart is reporting for Staff Maintenance images that was fixed in the last few months - DEV-6557 - which I think is the one this was fixed in - version 07.01.02.00.
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Re: Possible inventory save Image bug in 7.1

Postby Mike.Sheen » Mon Jul 23, 2018 5:48 pm

Yep - I can confirm DEV-6557 addressed this issue in staff and Inventory maintenance forms.

The problem seemed to only occur when saving as certain image types. For instance - I believe JPG causes the error, but not PNG.
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Re: Possible inventory save Image bug in 7.1

Postby SBarnes » Mon Jul 23, 2018 5:50 pm

No all image types produce the error, it creates a file but its blank.

By the way reverting to the default and saving that out works fine.
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Possible inventory save Image bug in 7.1  Topic is solved

Postby Mike.Sheen » Mon Jul 23, 2018 7:14 pm

Yes - we found it was when the image was jpg and you tried to save as png or vice-versa.

The code we ended up with (including the old problematic code commented out) is:

Code: Select all
' See https://stackoverflow.com/questions/1053052/a-generic-error-occurred-in-gdi-jpeg-image-to-memorystream
' And https://stackoverflow.com/questions/336387/image-save-throws-a-gdi-exception-because-the-memory-stream-is-closed
' GDI errors may occur when saving if you don't keep the stream open that the image was created from.
'
' So, the following will fail with "A generic error occurred in GDI+" if the image was jpg and saving as png, or vice versa:
'Using image As System.Drawing.Image = JiwaApplication.Manager.ByteArrayToImage(If(Inventory.Picture Is Nothing, Inventory.SystemSettings.DefaultPicture, Inventory.Picture))
'    Select Case DialogSave.FilterIndex
'        Case 1
'            image.Save(DialogSave.FileName, System.Drawing.Imaging.ImageFormat.Png)
'        Case 2
'            image.Save(DialogSave.FileName, System.Drawing.Imaging.ImageFormat.Jpeg)
'        Case 3
'            image.Save(DialogSave.FileName, System.Drawing.Imaging.ImageFormat.Bmp)
'        Case 4
'            image.Save(DialogSave.FileName, System.Drawing.Imaging.ImageFormat.Gif)
'    End Select
'End Using

' But, this works!
Using streamBitmap As New System.IO.MemoryStream(If(Inventory.Picture Is Nothing, Inventory.SystemSettings.DefaultPicture, Inventory.Picture))
   Using img = System.Drawing.Image.FromStream(streamBitmap)
      Select Case DialogSave.FilterIndex
         Case 1
            img.Save(DialogSave.FileName, System.Drawing.Imaging.ImageFormat.Png)
         Case 2
            img.Save(DialogSave.FileName, System.Drawing.Imaging.ImageFormat.Jpeg)
         Case 3
            img.Save(DialogSave.FileName, System.Drawing.Imaging.ImageFormat.Bmp)
         Case 4
            img.Save(DialogSave.FileName, System.Drawing.Imaging.ImageFormat.Gif)
      End Select
   End Using
End Using
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Re: Possible inventory save Image bug in 7.1

Postby SBarnes » Mon Jul 23, 2018 7:23 pm

Hi Mike,

Thanks for letting me know, by the way I suppose there is a similar thing with the web api pictures and documents i.e. you don't know the file/media type.
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Possible inventory save Image bug in 7.1

Postby Mike.Sheen » Mon Jul 23, 2018 7:39 pm

SBarnes wrote:Hi Mike,

Thanks for letting me know, by the way I suppose there is a similar thing with the web api pictures and documents i.e. you don't know the file/media type.


As far as the web api is concerned, images and documents are just byte arrays - but you can examine the first few bytes of the array to know with a reasonable degree of confidence what the image type is.

Converting from one type to another, however, is a completely different problem and not really within the scope of our web api.
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Re: Possible inventory save Image bug in 7.1

Postby SBarnes » Mon Jul 23, 2018 7:42 pm

Yes I know that trick but what about documents?
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Possible inventory save Image bug in 7.1

Postby Mike.Sheen » Mon Jul 23, 2018 10:31 pm

SBarnes wrote:Yes I know that trick but what about documents?


Hi Stuart,

Documents are - like the images in inventory maintenance - merely byte arrays as far as the web api is concerned - so the same applies - you can examine the first few bytes and from that determine if it is an image and what type of image.

We could add a static helper method to our bits - whether it be the web api or our assemblies to pass in a byte array and it return the image type (or "unknown") if that is any help.

Let us know if that would be useful - or if not let us know what ideally you'd want from us.

Mike
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Next

Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 16 guests

cron