Something to consider is that the signature doesn't have to be perfect. It's displaying on a receipt printer, so it can be a little pixelated. If you drop the resolution down to 100dpi, and you're printing a receipt printer, you'll only need maybe 400 pixels max, probably more like 300 horizontally, and then scaled down proportionately. That would greatly save on space even if you kept it in a PNG lossless format.
There's also a new lossless format (
called QOI) that has gotten good compression on certain types of files. It's a very simple algorithm, which is why it's gotten some attention. If there were a strong contrast between the white background and the actual signature portion it would compress nicely in that format due to its encoding scheme.
Keeping everything in its raw format isn't necessary in my thinking.
I wrote the crop to content algorithm last night, and have had the scale algorithm since the 00s. If there are other / better algorithms they can be implemented. Plus, the source code will be there to tweak as needed. The crop to content is looking for the first non-white pixels to find the content's inner edge, but I think something like GIMP's "Threshold" value would be more desirable, so something like this would allow you to pass in 15.0 which would allow some pixelation / dithering on the image to be ignored, and crop down to decent color contrasts. Colors of RGB(255,255,255) and RGB(254,255,255), etc. would be ignored in those cases as "white background" and ignored. Another would be to either sample the outer bands and derive the background color, or to pass in a reference color to use that as the background.
Code:
DECLARE INTEGER bmp_crop_to_content IN image.dll INTEGER nHandle, ;
FLOAT fThreshold && Add this parameter to make it work with dithered coloring, ;
INTEGER nRgb && Add this parameter to use a known background color, ;
INTEGER lAutoRgb && Add this parameter to pass in non-0 to have it auto-detect the background color
I almost wrote a GIMP competing product at one point. I had tried to work with the GIMP developers to add some features. They were very receptive at first, but as they researched about me online they mocked me for my faith. They stopped answering my questions and responding to my posts, so I moved on. I had wanted to create a
non-committal operator stack that allowed you to go back to some operation in the history of operations on the image, tweak the adjustments and have it filter through and affect all later applied operations. I also wanted to create a new type of image format I called
floan, which related to the original pixel dimensions in the source bitmap, processed down to the target. But rather than losing bits in scaling it would retain its original bit density, and simply apply the floans onto the projected image. I would've called it
Wonder. It would've done all the things I use GIMP for plus several more. I would've added a programming language to allow image objects to be created and operated on.
If only there were time.
--
Rick C. Hodgin