is it a bug in image.div

print("Before: ", img.get_pixel(1,1))
print("After: ", img.get_pixel(1,1))

Before: 166
After: 255

Are we missing a division after multipling with pScale

            int pScale = COLOR_GRAYSCALE_MAX - COLOR_GRAYSCALE_MIN; // <--------------- see this
            for (int i = 0, j = img->w; i < j; i++) {
                if ((!mask) || image_get_mask_pixel(mask, i, line)) {
                    int dataPixel = IMAGE_GET_GRAYSCALE_PIXEL_FAST(data, i);
                    int otherPixel = IMAGE_GET_GRAYSCALE_PIXEL_FAST(((uint8_t *) other), i);
                    int p = IM_DIV((invert?otherPixel:dataPixel) * pScale, (invert?dataPixel:otherPixel)); <------- And here
                    p = IM_MIN(p, COLOR_GRAYSCALE_MAX);

Hmm, maybe. I remember writing it like that for a reason. It had to do with the fact that if you divide two images with similar values you will end up with a valid image. If I divide by pScale again then you can’t divide two images by each other and get a valid result.

Um, given the above. I think I should change the documentation to say the output is multiplied by 255.

Should I add any input scaling on the input when the value to divide by is a scalar? The issue is that the pScale value differs by the image type.