String corruption with VipsForeignLoad / VipsForeignSave when using in Unity
See original GitHub issueWhen trying to use NetVips in Unity (2020.3.12f1), we are seeing string corruption issues with methods that call VipsForeignLoad
/ VipsForeignSave
:
For example:
public Image GetImage()
{
return Image.NewFromFile("/Users/jmillard/Desktop/test.png");
}
errors with:
VipsException: unable to load from file /Users/jmillard/Desktop/test.png
VipsForeignLoad: file "/Users/jmillard/Desktop/test.png�Le�" does not exist
and
var path = texture.GetUnityFilename(folder);
Debug.Log($"Writing to {path}");
var im = texture.GetImage();
File.WriteAllBytes(path, im.WriteToBuffer(".png"));
errors with:
VipsException: unable to write to buffer
VipsForeignSave: ".pngallrolling3" is not a known buffer format
We are seeing this on MacOS and Windows. (Did not try on Linux yet)
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
Constant data corruption in Text Component (maybe more)
I'm using Layout Group components and these components keep making changes in the scene even I didn't touch at all, mostly floating point...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
NetVips v2.0.1 is now available. Thanks for reporting this!
Thanks for these instructions, I could reproduce it on Windows. It seems that the Mono version provided by Unity doesn’t properly null-terminate strings(?), I was able to fix/workaround this with commit https://github.com/kleisauke/net-vips/commit/95a9627d7d48c6fa1ab97f80748e54aa38710eab (which should be available as nightly version 2.0.0 build number 277).
I’ll investigate further why this only occurs on Mono and not on .NET Core/Framework, in the meantime you might also be interested in these changes: https://github.com/freezy/VisualPinball.Engine/compare/refactor/scene-netvips-test...kleisauke:refactor/scene-netvips-test