├── LICENSE ├── README.md └── ascii_art.py /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 homeless-field 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ascii_art 2 | My very first Python project. Takes an image and makes it into ascii art, presented in your command prompt 3 | 4 | **Note:** This was my first project in Python, and isn't indicative of my current skills 5 | -------------------------------------------------------------------------------- /ascii_art.py: -------------------------------------------------------------------------------- 1 | # Import an image processing tool 2 | from PIL import Image 3 | 4 | # Decide what image to convert, and make it 1/3 the size 5 | image = Image.open("ctycgchr36231.jpg") 6 | image = image.resize((int(image.width / 3), int(image.height / 3))) 7 | 8 | # Define the ASCII characters and the variables 9 | characters = '.', '*', '$' 10 | text = '' 11 | a, b = 0, 0 12 | x, y, z = 0, 0, 0 13 | 14 | # For every pixel in the image... 15 | while y < image.height: 16 | # Find its brightness 17 | brightness = sum(image.getpixel((x, y))) / 3 18 | # Depending on its brightness, assign it an ASCII character 19 | while z < 3: 20 | a += 85 21 | if brightness <= a and brightness > b: 22 | text += characters[z] 23 | text += characters[z] 24 | b += 85 25 | z += 1 26 | z = 0 27 | a = 0 28 | b = 0 29 | if x == image.width - 1: 30 | text += '\n' 31 | y += 1 32 | x = 0 33 | else: 34 | x += 1 35 | 36 | #Print the output 37 | print(text) 38 | --------------------------------------------------------------------------------