Created
May 1, 2024 16:15
-
-
Save blopa/d059aabccd2b803099d72a00f71af2ee to your computer and use it in GitHub Desktop.
Code for post "Transforming manga pages for lazy western readers"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def overlay_flipped_with_transparent(base_image, transparent_image, final_output_image_path='final_output_image.png'): | |
flipped_base_image = base_image.transpose(Image.FLIP_LEFT_RIGHT).convert('RGBA') | |
if transparent_image.mode != 'RGBA': | |
transparent_image = transparent_image.convert('RGBA') | |
combined_image = Image.alpha_composite(flipped_base_image, transparent_image) | |
if final_output_image_path.lower().endswith('.jpg') or final_output_image_path.lower().endswith('.jpeg'): | |
combined_image = combined_image.convert('RGB') | |
combined_image.save(final_output_image_path) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment