ok this is very strange..... I added some debug.print lines to vb to find out certain values as it runs,
Now, the code is still the same as above, with the convert to 1bpp commented out, and when running it i get this:
Code: Select all
clsWorkerThread.ProcessBatch() GDVersion: 6.4
### R:\Originals\HB1003-210.tif ###
clsWorkerThread.ProcessBatch() ImageID: 44929140
clsWorkerThread.ProcessBatch() Tiff Compression: 4
clsWorkerThread.ProcessBatch() Added Border
clsWorkerThread.ProcessBatch() Detecting Width & Position of text. Width:539, Position: 5138
clsWorkerThread.ProcessBatch() Drawing Text
### R:\Output\HB1003-210.tif ###
Releasing Handle: 44929140
### R:\Originals\HB1003-211.tif ###
clsWorkerThread.ProcessBatch() ImageID: 46671700
clsWorkerThread.ProcessBatch() Tiff Compression: 4
clsWorkerThread.ProcessBatch() Added Border
clsWorkerThread.ProcessBatch() Detecting Width & Position of text. Width:539, Position: 5138
clsWorkerThread.ProcessBatch() Drawing Text
### R:\Output\HB1003-211.tif ###
Releasing Handle: 46671700
### R:\Originals\HB1003-212.tif ###
clsWorkerThread.ProcessBatch() ImageID: 31904084
clsWorkerThread.ProcessBatch() Tiff Compression: 4
clsWorkerThread.ProcessBatch() Added Border
clsWorkerThread.ProcessBatch() Detecting Width & Position of text. Width:539, Position: 5138
clsWorkerThread.ProcessBatch() Drawing Text
### R:\Output\HB1003-212.tif ###
Releasing Handle: 31904084
### R:\Originals\HB1003-213.tif ###
clsWorkerThread.ProcessBatch() ImageID: 89200600
clsWorkerThread.ProcessBatch() Tiff Compression: 4
clsWorkerThread.ProcessBatch() Added Border
clsWorkerThread.ProcessBatch() Detecting Width & Position of text. Width:539, Position: 5138
clsWorkerThread.ProcessBatch() Drawing Text
### R:\Output\HB1003-213.tif ###
Releasing Handle: 89200600
### R:\Originals\HB1003-214.tif ###
clsWorkerThread.ProcessBatch() ImageID: 2028841
clsWorkerThread.ProcessBatch() Tiff Compression: 4
clsWorkerThread.ProcessBatch() Added Border
clsWorkerThread.ProcessBatch() Detecting Width & Position of text. Width:539, Position: 5138
clsWorkerThread.ProcessBatch() Drawing Text
### R:\Output\HB1003-214.tif ###
Releasing Handle: 2028841
### R:\Originals\HB1003-215.tif ###
clsWorkerThread.ProcessBatch() ImageID: 82752320
clsWorkerThread.ProcessBatch() Tiff Compression: 4
clsWorkerThread.ProcessBatch() Added Border
clsWorkerThread.ProcessBatch() Detecting Width & Position of text. Width:539, Position: 5138
clsWorkerThread.ProcessBatch() Drawing Text
### R:\Output\HB1003-215.tif ###
Releasing Handle: 82752320
This outputs colour LZW files (because i havent converted to B&W).
Now, this is the strange thing. If i re-run the app, WITH the convert to B&W method, this is what happens:
Code: Select all
clsWorkerThread.ProcessBatch() GDVersion: 6.4
### R:\Originals\HB1003-210.tif ###
clsWorkerThread.ProcessBatch() ImageID: 10297793
clsWorkerThread.ProcessBatch() Tiff Compression: 4
clsWorkerThread.ProcessBatch() Added Border
clsWorkerThread.ProcessBatch() Detecting Width & Position of text. Width:539, Position: 5138
clsWorkerThread.ProcessBatch() Drawing Text
clsWorkerThread.ProcessBatch() ConvertTo1Bpp
### R:\Output\HB1003-210.tif ###
Releasing Handle: 10297793
### R:\Originals\HB1003-211.tif ###
clsWorkerThread.ProcessBatch() ImageID: 81322424
clsWorkerThread.ProcessBatch() Tiff Compression: 4
clsWorkerThread.ProcessBatch() Added Border
clsWorkerThread.ProcessBatch() Detecting Width & Position of text. Width:539, Position: 5138
clsWorkerThread.ProcessBatch() Drawing Text
clsWorkerThread.ProcessBatch() ConvertTo1Bpp
### R:\Output\HB1003-211.tif ###
Releasing Handle: 81322424
### R:\Originals\HB1003-212.tif ###
clsWorkerThread.ProcessBatch() ImageID: 54590480
clsWorkerThread.ProcessBatch() Tiff Compression: 4
clsWorkerThread.ProcessBatch() Added Border
clsWorkerThread.ProcessBatch() Detecting Width & Position of text. Width:539, Position: 5138
clsWorkerThread.ProcessBatch() Drawing Text
clsWorkerThread.ProcessBatch() ConvertTo1Bpp
### R:\Output\HB1003-212.tif ###
Releasing Handle: 54590480
### R:\Originals\HB1003-213.tif ###
clsWorkerThread.ProcessBatch() ImageID: 47181124
clsWorkerThread.ProcessBatch() Tiff Compression: 4
clsWorkerThread.ProcessBatch() Added Border
clsWorkerThread.ProcessBatch() Detecting Width & Position of text. Width:0, Position: 5408
clsWorkerThread.ProcessBatch() Drawing Text
clsWorkerThread.ProcessBatch() ConvertTo1Bpp
### R:\Output\HB1003-213.tif ###
Releasing Handle: 47181124
### R:\Originals\HB1003-214.tif ###
clsWorkerThread.ProcessBatch() ImageID: 67060184
clsWorkerThread.ProcessBatch() Tiff Compression: 4
clsWorkerThread.ProcessBatch() Added Border
clsWorkerThread.ProcessBatch() Detecting Width & Position of text. Width:0, Position: 5408
clsWorkerThread.ProcessBatch() Drawing Text
clsWorkerThread.ProcessBatch() ConvertTo1Bpp
### R:\Output\HB1003-214.tif ###
Releasing Handle: 67060184
### R:\Originals\HB1003-215.tif ###
clsWorkerThread.ProcessBatch() ImageID: 24231780
clsWorkerThread.ProcessBatch() Tiff Compression: 4
clsWorkerThread.ProcessBatch() Added Border
clsWorkerThread.ProcessBatch() Detecting Width & Position of text. Width:0, Position: 5408
clsWorkerThread.ProcessBatch() Drawing Text
clsWorkerThread.ProcessBatch() ConvertTo1Bpp
### R:\Output\HB1003-215.tif ###
Releasing Handle: 24231780
Notice how, after the 3rd image, it stops detecting the width of the text it wants to draw. Also, the first 3 images are STILL colour (as if the convertto1bpp is failing) then after the 3rd image they do start converting to b&w but the method used to detect the width of text starts returning 0.
this is very strange.
All the images are group4fax to start with.
this is my code
Code: Select all
Debug.Print("clsWorkerThread.ProcessBatch() GDVersion: " & imaging.GetVersion())
'Open Image
Debug.Print("### " & OneBatchItem.inFile & " ###")
ImageID = imaging.CreateGdPictureImageFromFile(OneBatchItem.inFile)
Debug.Print("clsWorkerThread.ProcessBatch() ImageID: " & ImageID)
Debug.Print("clsWorkerThread.ProcessBatch() Tiff Compression: " & imaging.GetTiffCompression(ImageID))
imaging.AddBorderBottom(ImageID, 140, Color.White)
Debug.Print("clsWorkerThread.ProcessBatch() Added Border")
TextWidth = imaging.GetTextWidth(ImageID, Replace(My.Computer.FileSystem.GetName(OneBatchItem.inFile).Substring(0, Len(My.Computer.FileSystem.GetName(OneBatchItem.inFile)) - 4), "-", "/"), "Arial", 32, GdPicture.FontStyle.FontStyleRegular)
TextWidthPos = (imaging.GetWidth(ImageID) / 2) - (TextWidth / 2)
Debug.Print("clsWorkerThread.ProcessBatch() Detecting Width & Position of text. Width:" & TextWidth & ", Position: " & TextWidthPos)
imaging.DrawText(ImageID, Replace(My.Computer.FileSystem.GetName(OneBatchItem.inFile).Substring(0, Len(My.Computer.FileSystem.GetName(OneBatchItem.inFile)) - 4), "-", "/"), TextWidthPos, imaging.GetHeight(ImageID) - 120, 32, GdPicture.FontStyle.FontStyleRegular, Color.Black, "Arial", True)
Debug.Print("clsWorkerThread.ProcessBatch() Drawing Text")
imaging.ConvertTo1Bpp(ImageID)
Debug.Print("clsWorkerThread.ProcessBatch() ConvertTo1Bpp")
Debug.Print("### " & OneBatchItem.outFile & " ###")
imaging.SaveAsTIFF(ImageID, OneBatchItem.outFile, GdPicture.TiffCompression.TiffCompressionCCITT4)
Debug.Print("Releasing Handle: " & ImageID)
imaging.ReleaseGdPictureImage(ImageID)
Debug.Print("")
Maybe if you can't reproduce this, its something with my image files, but they open and convert in any image editing program