Support Pallete-based PNG w. transparency #32
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
PNG with transparency is not rendered collectly in generated PDF, because Prawn does not support Palleted-PNG with transparency prawnpdf/prawn#783 .
Getting this problem
Sample palleted PNG:
Sample script:
Sample thinreports-layout-file:
Result PDF:
Solution
Automatically convert color-mode of the image to True-color with alpha-channel using ChunkyPNG if an image is pallete-based PNG with transparency when
convert_paletted_transparency_png
configuration is settrue
(default isfalse
)Enabling this feature
This feature is disabled by default. If you want to enable, you need to set
true
toconvert_palleted_transparency_png
as below:Note for impact on performance
このオプションを有効にすると、使用されるすべての画像に対して、下記の処理が行われます:
(3) の処理によって一度キャッシュされた画像は、以降上記処理は実行されませんが、それでもこの機能が有効でない状態と比べてパフォーマンスが低下することは避けられません。
画像を多く使用する場合やパフォーマンスがシビアな場合などは、予め画像を変換するなどして、この機能の使用を避けることを検討した方が良いかもしれません。