Example #1
0
def main():
    signal.signal(signal.SIGINT, signal_handler)
    console = Console()

    global gruvbox_factory
    gruvbox_factory = GoNord()
    gruvbox_factory.reset_palette()
    add_gruvbox_palette()

    console.print(
        Panel('🏭 [bold green] Gruvbox Factory [/] 🏭',
              expand=False,
              border_style='yellow'))
    console.print(
        '⚠️ WARNING ⚠️\n[italic]make sure you\'re in the same directory of the image you want to convert [/]\n'
    )
    image_file = console.input(
        '🖼️ [bold yellow]Which image do you want to manufacture?[/] ')

    try:
        image = gruvbox_factory.open_image(image_file)
    except:
        console.print(
            '❌ [red]We had a problem in the pipeline! Make sure you\'re in the same path of the image you want to convert! [/]'
        )
        sys.exit(0)
    console.print('🔨 [yellow]manufacturing your gruvbox wallpaper...[/]')
    gruvbox_factory.convert_image(image, save_path=('gruvbox_' + image_file))

    console.print('✅ [bold green]Done![/] [green](saved as gruvbox_' +
                  image_file + ')[/]')
Example #2
0
def main():
    dirOld = "/home/mir/Pictures/wallhaven/"
    dirNew = "/home/mir/Pictures/newWall/"
    for root, dirs, files in os.walk(dirOld):
        for file in files:
            imagePath = dirOld + file
            name = file.split(".", 1)
            oName = name[0] + "-Nord." + name[1]
            savePath = dirNew + oName

            # E.g. Replace pixel by pixel
            go_nord = GoNord()
            image = go_nord.open_image(imagePath)
            go_nord.convert_image(image, save_path=savePath)
        
            # E.g. Avg algorithm and less colors
            go_nord.enable_avg_algorithm()
            go_nord.reset_palette()
            go_nord.add_file_to_palette(NordPaletteFile.POLAR_NIGHT)
            go_nord.add_file_to_palette(NordPaletteFile.SNOW_STORM)
        
            # You can add color also by their hex code
            go_nord.add_color_to_palette("#FF0000")
        
            image = go_nord.open_image(imagePath)
            go_nord.convert_image(image, save_path=savePath)
        
            # E.g. Resized img no Avg algorithm and less colors
            go_nord.disable_avg_algorithm()
            go_nord.reset_palette()
            go_nord.add_file_to_palette(NordPaletteFile.POLAR_NIGHT)
            go_nord.add_file_to_palette(NordPaletteFile.SNOW_STORM)
        
            image = go_nord.open_image(imagePath)
            resized_img = go_nord.resize_image(image)
            go_nord.convert_image(resized_img, save_path=savePath)
        
            # E.g. Quantize
        
            image = go_nord.open_image(imagePath)
            go_nord.reset_palette()
            go_nord.set_default_nord_palette()
            quantize_image = go_nord.quantize_image(image, save_path=savePath)
        
            # To base64
            go_nord.image_to_base64(quantize_image, "jpeg")
Example #3
0
#!/usr/bin/env python

import argparse
from ImageGoNord import GoNord

parser = argparse.ArgumentParser(
    description='convert image palette to specified palette')
parser.add_argument('colorscheme', type=str, help='name of the colorscheme')
parser.add_argument('image', type=str, help='path to the image')
args = parser.parse_args()

path = "/home/samy/.config/colorschemes/" + args.colorscheme

with open(path, 'r') as f:
    lines = f.readlines()

colors = [line.split()[2] for line in lines]

go_nord = GoNord()
go_nord.reset_palette()
for color in colors:
    go_nord.add_color_to_palette(color)

print(args.image)
image = go_nord.open_image(args.image)
go_nord.convert_image(image, save_path='/home/samy/Wallpapers/wall.png')
Example #4
0
from ImageGoNord import NordPaletteFile, GoNord

go_nord = GoNord()
"""image = go_nord.open_image("images/test-profile.jpg")
go_nord.convert_image(image, save_path='images/test.processed.jpg') """

# E.g. Avg algorithm and less colors
go_nord.enable_avg_algorithm()
go_nord.reset_palette()
# go_nord.add_file_to_palette(NordPaletteFile.POLAR_NIGHT)
# go_nord.add_file_to_palette(NordPaletteFile.SNOW_STORM)
# go_nord.add_color_to_palette('#FF0000')
go_nord.set_default_nord_palette()

image = go_nord.open_image("images/test.jpg")
go_nord.convert_image(image, save_path='images/test.avg.jpg')

# E.g. Resized img no Avg algorithm and less colors
go_nord.disable_avg_algorithm()
go_nord.reset_palette()
go_nord.add_file_to_palette(NordPaletteFile.POLAR_NIGHT)
go_nord.add_file_to_palette(NordPaletteFile.SNOW_STORM)

image = go_nord.open_image("images/test.jpg")
resized_img = go_nord.resize_image(image)
go_nord.convert_image(resized_img, save_path='images/test.resized.jpg')

# E.g. Quantize

image = go_nord.open_image("images/test.jpg")
go_nord.reset_palette()
        go_nord.set_default_nord_palette()
        go_nord.enable_avg_algorithm()

        for palette_key in FLAIR:
            go_nord.reset_palette()
            IGN_TITLE_PREFIX = '[' + palette_key + '] '
            for hex_color in FLAIR[palette_key]['hex_colors']:
                go_nord.add_color_to_palette(hex_color)

            im = go_nord.base64_to_image(
                base64.b64encode(requests.get(sub['url']).content))

            img_path = 'images/' + sub['uniqid'] + '.' + sub['url'][-3:]
            print('Processing ' + sub['title'])
            try:
                go_nord.convert_image(im, save_path=img_path)
                print('Uploading ' + sub['title'])
                reddit_sub = imagegonord_subreddit.submit_image(
                    IGN_TITLE_PREFIX + sub['title'] + IGN_TITLE_SUFFIX,
                    image_path=img_path,
                    flair_id=FLAIR[palette_key]['id'])

                print('Commenting')
                reddit_sub.reply(
                    'The ImageGoWild website is available [here](https://ign.schrodinger-hat.it/color-schemes) as part of ImageGoNord project, try it and share the result in [r/ImageGoNord](https://www.reddit.com/r/ImageGoNord/)!\nOriginal image made by ['
                    + sub['author'] + '](https://www.reddit.com/user/' +
                    sub['author'] + ') available [here](' + sub['url'] + ').')
            except Exception as e:
                print(e)

        published_post = published_post + 1
Example #6
0
                                confarg.logs["pals"][3].format(palette_color))
                else:
                    PALETTE_CHANGED = True
                    to_console(confarg.logs["pals"][0].format(
                        palette.capitalize()))
                    palette_path = src_path + "/palettes/" + palette.capitalize(
                    ) + "/"
                    go_nord.reset_palette()
                    palette_set = [
                        palette_file.replace(".txt", '')
                        for palette_file in listdir(palette_path)
                    ]
                    go_nord.set_palette_lookup_path(palette_path)
                    for palette_color in palette_set:
                        go_nord.add_file_to_palette(palette_color + ".txt")

    if not PALETTE_CHANGED:
        to_console(confarg.logs["pals"][4])
        palette_path = src_path + "/palettes/Nord/"
        go_nord.reset_palette()
        palette_set = [
            palette_file.replace(".txt", '')
            for palette_file in listdir(palette_path)
        ]
        go_nord.set_palette_lookup_path(palette_path)
        for palette_color in palette_set:
            go_nord.add_file_to_palette(palette_color + ".txt")

    quantize_image = go_nord.convert_image(image, save_path=OUTPUT_IMAGE_NAME)
    sys.exit(0)
Example #7
0
from ImageGoNord import NordPaletteFile, GoNord

# E.g. Replace pixel by pixel
go_nord = GoNord()
image = go_nord.open_image("images/test.jpg")
go_nord.convert_image(image, save_path='images/test.processed.jpg')

# E.g. Avg algorithm and less colors
go_nord.enable_avg_algorithm()
go_nord.reset_palette()
go_nord.add_file_to_palette(NordPaletteFile.POLAR_NIGHT)
go_nord.add_file_to_palette(NordPaletteFile.SNOW_STORM)

# You can add color also by their hex code
go_nord.add_color_to_palette('#FF0000')

image = go_nord.open_image("images/test.jpg")
go_nord.convert_image(image, save_path='images/test.avg.jpg')

# E.g. Resized img no Avg algorithm and less colors
go_nord.disable_avg_algorithm()
go_nord.reset_palette()
go_nord.add_file_to_palette(NordPaletteFile.POLAR_NIGHT)
go_nord.add_file_to_palette(NordPaletteFile.SNOW_STORM)

image = go_nord.open_image("images/test.jpg")
resized_img = go_nord.resize_image(image)
go_nord.convert_image(resized_img, save_path='images/test.resized.jpg')

# E.g. Quantize