Skip to content

Fix invalid PNG bit depth when using deprecated --colours arg#4971

Open
felixbuenemann wants to merge 1 commit intolibvips:masterfrom
felixbuenemann:fix-colours-bitdepth-calculation
Open

Fix invalid PNG bit depth when using deprecated --colours arg#4971
felixbuenemann wants to merge 1 commit intolibvips:masterfrom
felixbuenemann:fix-colours-bitdepth-calculation

Conversation

@felixbuenemann
Copy link
Collaborator

ceil(log2(colours)) can produce non-power-of-two values (e.g. 5 for --colours 32) which libpng rejects.
Use g_bit_storage() to compute the minimum bits needed, then round up to a valid PNG palette bit depth (1, 2, 4, or 8).

ceil(log2(colours)) can produce non-power-of-two values (e.g. 5 for
--colours 32) which libpng rejects. Use g_bit_storage() to compute
the minimum bits needed, then round up to a valid PNG palette bit
depth (1, 2, 4, or 8).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant