├── requirements.txt ├── example.png ├── .gitignore ├── LICENSE ├── README.md └── conv.py /requirements.txt: -------------------------------------------------------------------------------- 1 | rich==9.8.2 2 | image-go-nord==0.1.3 3 | -------------------------------------------------------------------------------- /example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/siddrs/tokyo-night-factory/HEAD/example.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # python 2 | *.egg-info/ 3 | dist/ 4 | build/ 5 | 6 | # manufactured images 7 | factory/*.png 8 | factory/*.jpg 9 | 10 | # === macOS === 11 | .DS_Store 12 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Paulo Pacitti 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. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 🗼Tokyo Night Factory 🏭 2 | Forked from [nord-factory](https://github.com/13ace37/nord-factory) 😄 3 | 4 | A simple cli to convert any image to a tokyo-night themed wallpaper 5 | 6 | ![example](./example.png) 7 | 8 | ## Installation 9 | 1. Clone the repo. 10 | 2. Install the required packages using pip as shown below: 11 | ``` 12 | pip3 install rich image-go-nord argparse 13 | ``` 14 | ## Usage 15 | Go to the directory containing the `conv.py` script and run it using: 16 | ``` 17 | python3 conv.py 18 | ``` 19 | 20 | Then follow the on-screen instructions, and voila you'll have your tokyo-night themed image ready in no time! 21 | 22 | 23 | ## Note 24 | The output image usually doesn't look good when the input image is complex or has a lot of colors. It works best with simple minimal images with a few colors like the image shown above. Keep this in mind 25 | 26 | ## Credits 27 | - [Tokyo Night colorscheme by enkia](https://github.com/enkia/tokyo-night-vscode-theme) 28 | - **Made** with [Schrodinger-Hat's ImageGoNord](https://github.com/Schrodinger-Hat), but with the tokyo-night palette 29 | - **Text User Interface (TUI)** made with [rich](https://github.com/willmcgugan/rich) 30 | -------------------------------------------------------------------------------- /conv.py: -------------------------------------------------------------------------------- 1 | import signal 2 | import argparse 3 | import sys 4 | import os 5 | from pathlib import Path 6 | 7 | from ImageGoNord import GoNord 8 | 9 | from rich.console import Console 10 | from rich.panel import Panel 11 | 12 | def main(): 13 | 14 | signal.signal(signal.SIGINT, signal_handler) 15 | console = Console() 16 | 17 | tn_factory = GoNord() 18 | tn_factory.reset_palette() 19 | add_tn_palette(tn_factory) 20 | 21 | # Checks if there's an argument 22 | if len(sys.argv) > 1: 23 | image_paths = fromCommandArgument(console) 24 | else: 25 | image_paths = fromTui(console) 26 | 27 | for image_path in image_paths: 28 | if os.path.isfile(image_path): 29 | process_image(image_path, console, tn_factory) 30 | else: 31 | console.print( 32 | f"❌ [red]We had a problem in the pipeline! \nThe image at '{image_path}' could not be found! \nSkipping... [/]" 33 | ) 34 | continue 35 | 36 | # Gets the file path from the Argument 37 | def fromCommandArgument(console): 38 | command_parser = argparse.ArgumentParser( 39 | description="A simple cli to manufacture Tokyo Night themed wallpapers." 40 | ) 41 | command_parser.add_argument( 42 | "Path", metavar="path", nargs="+", type=str, help="The path(s) to the image(s)." 43 | ) 44 | args = command_parser.parse_args() 45 | 46 | return args.Path 47 | 48 | # Gets the file path from user input 49 | def fromTui(console): 50 | 51 | console.print( 52 | Panel( 53 | "🏭 [bold magenta] Tokyo-Night Factory [/] 🏭", expand=False, border_style="magenta" 54 | ) 55 | ) 56 | 57 | return [ 58 | os.path.expanduser(path) 59 | for path in console.input( 60 | "🖼️ [bold yellow]Which image(s) do you want to manufacture? (image paths separated by spaces):[/] " 61 | ).split() 62 | ] 63 | 64 | def process_image(image_path, console, tn_factory): 65 | image = tn_factory.open_image(image_path) 66 | 67 | console.print(f"🔨 [blue]manufacturing '{os.path.basename(image_path)}'...[/]") 68 | 69 | # TODO: might be a better idea to save the new Image in the same directory the command is being run from 70 | save_path = os.path.join( 71 | os.path.dirname(image_path), "tn-" + os.path.basename(image_path) 72 | ) 73 | 74 | tn_factory.convert_image(image, save_path=(save_path)) 75 | console.print(f"✅ [bold green]Done![/] [green](saved at '{save_path}')[/]") 76 | 77 | def add_tn_palette(tn_factory): 78 | 79 | tnPalette = ["#16161E","#1a1b26","#24283b","#414868","#565f89","#cfc9c2","#9aa5ce","#a9b1d6","#c0caf5","#bb9af7","#7aa2f7","#7dcfff","#2ac3de","#b4f9f8","#9ece6a","#e0af68","#ff9e64","#f7768e"] 80 | 81 | for color in tnPalette: 82 | tn_factory.add_color_to_palette(color) 83 | 84 | ## handle CTRL + C 85 | def signal_handler(signal, frame): 86 | print() 87 | sys.exit(0) 88 | 89 | if __name__ == "__main__": 90 | main() 91 | --------------------------------------------------------------------------------