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
We have a business case where we need PHP to return a 1-bit depth BMP image to the client. This is because the client is outputting the image to a thermal receipt printer which can only handle 1-bit or 4-bit depth images. The imagebmp() function does not currently have a parameter to specify the color depth; it probably should. The documentation did not specify what the color depth of the generated image was by default.
Ideally, it would be nice to have a function with the following signature:
Makes generally sense to me (and thanks for the code :) I'm not sure whether the color depth should even be specified by the user; what happens if there are more colors in the palette (or in truecolor images).
Anyhow, that would need first be addressed upstream, so please file an ticket there.
The imagebmp() function does not currently have a parameter to specify the color depth; it probably should. The documentation did not specify what the color depth of the generated image was by default.
libgd uses a simple solution: truecolor images are stored as 24bit, palette images are stored as 8bit BMPs. I agree that this should be documented.
Description
We have a business case where we need PHP to return a 1-bit depth BMP image to the client. This is because the client is outputting the image to a thermal receipt printer which can only handle 1-bit or 4-bit depth images. The imagebmp() function does not currently have a parameter to specify the color depth; it probably should. The documentation did not specify what the color depth of the generated image was by default.
Ideally, it would be nice to have a function with the following signature:
imagebmp(GdImage $image, resource|string|null $file = null, bool $compressed = true, int $colorDepth = 24): bool
We worked around this issue by writing a user-defined function:
The text was updated successfully, but these errors were encountered: