[py-tx][mlh] Add un-letterboxing reference implementation to Photo Content Type #1666
Labels
mlh
Related to Major League Hacking Fellowship
python-threatexchange
Items related to the threatexchange python tool / library
Goal:
Provide a method in Photo content type which, given an image, returns either the same image, or a smaller image that has square black boxes removed from the side.
Example
Take this image:
![Image](https://private-user-images.githubusercontent.com/1654004/378862142-7f0703df-e7ba-4d1f-94b3-146e229ae8b4.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkzMzU5MjIsIm5iZiI6MTczOTMzNTYyMiwicGF0aCI6Ii8xNjU0MDA0LzM3ODg2MjE0Mi03ZjA3MDNkZi1lN2JhLTRkMWYtOTRiMy0xNDZlMjI5YWU4YjQucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxMiUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTJUMDQ0NzAyWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9OWQ2NjI1NmNjNzdjZTNmNjZiNjgyZjFmOGU5Yjc5NDlkNmY3MzIyMmVlNzA1NDE2ZGQwN2QzYmMyZGM3YWZlZiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.Irr49JQj87pqyS1GlLGXnB7LPJ1dXQuXbtqQOovRoqw)
Given this "letterboxed" version of the image, the return should be the first image.
![Image](https://private-user-images.githubusercontent.com/1654004/378861953-2df01578-6044-47bf-abe6-d4c339a43e07.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkzMzU5MjIsIm5iZiI6MTczOTMzNTYyMiwicGF0aCI6Ii8xNjU0MDA0LzM3ODg2MTk1My0yZGYwMTU3OC02MDQ0LTQ3YmYtYWJlNi1kNGMzMzlhNDNlMDcucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxMiUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTJUMDQ0NzAyWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9YzM4NDM0Nzc3MzE2ZDhkZTk5YTFmMzI2Mzg0ODdlZTdhZWE1NTJlZjQ2ZDBmMDQxOWFmZDdiYmIwZmQ0MDY2ZiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.426QwBLUS-NAzyoDUtNK7mMN-rb_TAMKKGcZ-oDGvyk)
Demonstrating
Add a new flag to
tx hash
that will allow preprocessing steps for imagesImplementing
Try to avoid pulling in new dependencies if you can, even though there are a million libraries that might already solve this. Instead, take a look at the image libraries already included, such as Pillow - there is robust documentation.
Testing
Include a unittest that demonstrates the functionality, including edge cases you might consider. Use the bridge mod photos, either algorithmically updating them
The text was updated successfully, but these errors were encountered: