I'm faced with weird GdPicture 9.2.4 behavior. In multithreading environment I want to convert some files to 8bb 216. Most of the files are converted normally but some of them are not - they are converted to different sizes compared to most of the resulting files. In my tests, source files (all they are the same file under different name) have these characteristic:
Source file:
Compression = CCITT T.4
DPI = 600
Bit depth = 1
Dimensions = 4968 x 7016
Size = 334 KB
After applying the same conversions to all my source files (100 in count - all are the same file under different name), I have the following 3 types of resulting files:
--------------------------------
Compression = LZW
DPI = 21
Bit depth = 8
Dimensions = 117 x 164
Size = 4,85 KB
--------------------------------
Comression = LZW
DPI = 42
Bit depth = 8
Dimensions = 348 x 491
Size = 8,48 KB
--------------------------------
Comression = LZW
DPI = 42
Bit depth = 8
Dimensions = 348 x 491
Size = 33,8 KB
--------------------------------
The last two files, even thou their characteristics look very similar (except file size) the image looks very different - the smaller file looks more like 1 bit compared to bigger one which looks more like 8 bit.
The resulting files are attached. Here is very simple code that produces this bug:
Code: Select all
var files = Directory.GetFiles(@"C:\PathWithAtLeast100Files","*.tif");
var po = new ParallelOptions { MaxDegreeOfParallelism = 6 };
Parallel.ForEach(files, po, (file, pls, idx) => {
var gdp = new GdPictureImaging();
var imageId = gdp.CreateGdPictureImageFromFile(file);
gdp.ConvertTo8Bpp216(imageId);
gdp.Scale(imageId, 7, System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic);
gdp.SaveAsTIFF(imageId, file + ".converted.tif", TiffCompression.TiffCompressionLZW);
gdp.ReleaseGdPictureImage(imageId);
gdp.Dispose();
});
Also if I remove either call to ConvertTo8Bpp216 or Scale methods, everything is OK. The problem persists only if these two calls are processed in this sequence. I have experience this bug even if i set MaxDegreeOfParallelism = 1 (which, hopefully, process files sequentially) - it produces one smallest file (4,85 KB) and all other were bigger one (33,8 KB). I think that every time I start the test with MaxDegreeOfParallelism = 1 (or simple for loop instead of Threads/Tasks), only the second file becomes 4,85 KB.
If this makes any sense - I'm using GdPicture 9.2.4 .NET 3.5 version with 32 bit "filters" file from 32 bit .NET 4 console application.