You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When we call image.WriteToBuffer with a shared VOption, we receive an error:
Problematic:(Run in parallel)
var option = new VOption() { { "Q", JpegQuality } };
using var thumb = image.ThumbnailImage(250);
var thumbData = thumb.WriteToBuffer(".jpg", option);
thumb.Close();
Works:
using var thumb = image.ThumbnailImage(250);
var thumbData = thumb.WriteToBuffer(".jpg", new VOption() { { "Q", JpegQuality } });
thumb.Close();
Message:
at System.ThrowHelper.ThrowAddingDuplicateWithKeyArgumentException[T](T key)
at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
at NetVips.ExtensionMethods.Merge(VOption self, VOption merge)
at NetVips.Image.WriteToBuffer(String formatString, VOption kwargs)
So the cause and the possible fixes:
Image.WriteToBuffer calls kwargs.Merge with the stringOptions
This calls VOption's this[string key]'s set method:
{
get => _internalDictionary[key];
set => Add(key, value);
}
Which then calls this: public void Add(string key, object value) => _internalDictionary.Add(key, value);
The problem with dictionary.Add is, non-repeatability.
We use a workaround in our code now while calling.
But in the code there are 2 easy solution options:
Commit 7b723e3 should fix this. Thanks for reporting this!
If you want to test this, you can use the nightly version of NetVips. Add the https://ci.appveyor.com/nuget/net-vips feed in the <packageSources> section of your NuGet.config:
When we call image.WriteToBuffer with a shared VOption, we receive an error:
Problematic:(Run in parallel)
Works:
Message:
So the cause and the possible fixes:
Image.WriteToBuffer
callskwargs.Merge
with thestringOptions
ExtensionMethods.Merge
callsVOption[key] = value;
this[string key]
'sset
method:public void Add(string key, object value) => _internalDictionary.Add(key, value);
The problem with dictionary.Add is, non-repeatability.
We use a workaround in our code now while calling.
But in the code there are 2 easy solution options:
Add(string key, object value) => _internalDictionary[key] = value;
Set(string key, object value) => _internalDictionary[key] = value;
and call it from
set => Set(key, value);
The text was updated successfully, but these errors were encountered: