World Conquest Chronicles

World Conquest Chronicles

White Generator, v2.0

Utility for a generation of memes.

Refactoring and option enhancements.

Change Log

  • Closed issues:
    • Refactoring:
      • Support for separate options in the classes from the types.py file #25
      • Cover the project code with unit tests #26
      • Use the type hints over the project code #27
    • New features:
      • Support for working with a default font #31
      • Support for negative text rectangle coordinates (with wrapping) #32
      • Support for resizing a background image #36
    • Option enhancements:
      • Support for a default output path #29
      • Support for disabling the protection against duplicate meme texts #30
      • Store notes in the home directory by constant path #33
    • Misc.:
      • Migrate to the pyproject.toml configuration #23
      • Update the dependencies #24
      • Add the Makefile with the basic commands #34
  • Fixed bugs:
    • Fix the bug with the generation expression #28
    • Font descent is not taken into account when obtaining a bounding box of text #39

Features

  • a generation of memes (in PNG format);
  • a support of plain and graphic backgrounds;
  • a specification of a text rectangle;
  • a support of horizontal and vertical text alignments;
  • a read of memes texts from a file (each text is separated from another by a double newline);
  • a support single-line and multiline memes texts;
  • a protection against duplicate memes texts (it's optional);
  • a support of a watermark (it's optional);
  • meme settings:
    • background:
      • color;
      • width;
      • height;
      • image:
        • it supports the same formats as Pillow library;
        • it'll be resized to the specified size (it's optional);
      • resizing filter;
    • text:
      • font:
        • it supports only TrueType fonts;
        • it's optional (if none, the Pillow library's default font is used);
      • size;
      • color;
      • rectangle:
        • left;
        • rigth (if the value is negative, the image width is added to it);
        • top;
        • bottom (if the value is negative, the image height is added to it);
      • horizontal alignment;
      • vertical alignment;
    • watermark:
      • font (it always uses the text font);
      • text;
      • size;
      • color.

Usage

$ white-generator -v | --version
$ white-generator -h | --help
$ white-generator [options] (-i INPUT_FILE | --input-file INPUT_FILE)

Options:

  • -v, --version — show the version message and exit;
  • -h, --help — show this help message and exit;
  • -i INPUT_FILE, --input-file INPUT_FILE — the path to the file with notes;
  • -o OUTPUT_PATH, --output-path OUTPUT_PATH — the path for generated images (default: output);
  • -l TEXT_RECTANGLE_LEFT, --text-rectangle-left TEXT_RECTANGLE_LEFT — the left text position (default: 0);
  • -t TEXT_RECTANGLE_TOP, --text-rectangle-top TEXT_RECTANGLE_TOP — the top text position (default: 0);
  • -R TEXT_RECTANGLE_RIGHT, --text-rectangle-right TEXT_RECTANGLE_RIGHT — the horizontal text limit (if the value is negative, the image width is added to it; default: -1);
  • -B TEXT_RECTANGLE_BOTTOM, --text-rectangle-bottom TEXT_RECTANGLE_BOTTOM — the vertical text limit (if the value is negative, the image height is added to it; default: -1);
  • -a {left,center,right}, --text-horizontal-align {left,center,right} — the text horizontal alignment (default: center);
  • -A {top,center,bottom}, --text-vertical-align {top,center,bottom} — the text vertical alignment (default: center);
  • -W IMAGE_WIDTH, --image-width IMAGE_WIDTH — the image width (default: 640);
  • -H IMAGE_HEIGHT, --image-height IMAGE_HEIGHT — the image height (default: 480);
  • -b IMAGE_BACKGROUND_COLOR, --image-background-color IMAGE_BACKGROUND_COLOR — the image background color (default: rgb(255, 255, 255));
  • -I IMAGE_BACKGROUND_IMAGE, --image-background-image IMAGE_BACKGROUND_IMAGE — the path to the background image (default: none);
  • -F {nearest,box,bilinear,hamming,bicubic,lanczos}, --image-resizing-filter {nearest,box,bilinear,hamming,bicubic,lanczos} — the resizing filter for the background image (default: lanczos);
  • -f TEXT_FONT_FILE, --text-font-file TEXT_FONT_FILE — the path to the font file (if none, the Pillow library's default font is used; default: none);
  • -s TEXT_FONT_SIZE, --text-font-size TEXT_FONT_SIZE — the font size (default: 25);
  • -c TEXT_FONT_COLOR, --text-font-color TEXT_FONT_COLOR — the font color (default: rgb(0, 0, 0));
  • -w WATERMARK_TEXT, --watermark-text WATERMARK_TEXT — the watermark text (default: none);
  • -S WATERMARK_SIZE, --watermark-size WATERMARK_SIZE — the watermark font size (default: 12);
  • -C WATERMARK_COLOR, --watermark-color WATERMARK_COLOR — the watermark font color (default: rgb(128, 128, 128));
  • --no-database — don't filter notes by database;
  • --no-resizing — don't resize the background image.

Repository

Link: https://github.com/thewizardplusplus/white-generator/tree/v2.0.

Content: code.

License: MIT.