コード例 #1
0
ファイル: main.py プロジェクト: Gnoxter/ascii_py
def main():
    parser = OptionParser()
    parser.add_option("-o", "--out", dest = "filename", default = "out.jpg",
            help = "The filename you want your final image saved as")
    parser.add_option("-w", "--words", dest = "words", default = "#",
            help = "Use words to create your image")
    parser.add_option("-s", "--step", dest = "step", type = "int", default = 3,
            help = "Choose the distance of your characters")
    parser.add_option("-d", "--density", action="store_true", dest='density',
            help="Adding the flag converts the image based on visual density")
    parser.add_option("-t", "--terminal", action="store_true", dest='terminal',
            help="Print ascii image to terminal")

    (options, args) = parser.parse_args()

    if len(args) > 0:
        in_file = args[0]
    else:
        print "Failed to provide an input image"
        return

    a = Ascii(in_file)

    if options.density:
        a.density_artify(step=options.step)
        a.save(options.filename)

    elif options.terminal:
        a.terminal_artify()

    else:
        a.word_artify(options.words, options.step)
        a.save(options.filename)
コード例 #2
0
    def save_img(self):
        in_file = self.in_line.text()
        step = self.step_line.text()
        words = self.words_line.text()

        if step.isdigit():
            step = int(step)
        else:
            step = 3

        if words == "":
            words = "#"

        if not os.path.exists(in_file):
            QMessageBox().warning(None, "Error", "Input file does not exist",
                                  QMessageBox.StandardButton.Ok)
            return
        output_file = self.get_output_file()

        if not (output_file.lower().endswith(".jpg")
                or output_file.lower().endswith(".png")
                or output_file.lower().endswith(".jpeg")):
            output_file += ".jpg"

        a = Ascii(in_file)
        a.word_artify(words, step)
        a.save(output_file)
コード例 #3
0
ファイル: main-gui.py プロジェクト: Silvus/ascii_py
    def save_img(self):
        in_file  = self.in_line.text()
        step     = self.step_line.text()
        words    = self.words_line.text()

        if step.isdigit():
            step = int(step)
        else:
            step = 3

        if words == "":
            words = "#"

        if not os.path.exists(in_file):
            QMessageBox().warning(None, "Error", "Input file does not exist",
                    QMessageBox.StandardButton.Ok)
            return
        output_file = self.get_output_file()

        if not (output_file.lower().endswith(".jpg") or
                output_file.lower().endswith(".png") or
                output_file.lower().endswith(".jpeg")):
            output_file += ".jpg"

        a = Ascii(in_file)
        a.word_artify(words, step)
        a.save(output_file)
コード例 #4
0
def main():
    parser = OptionParser()
    parser.add_option("-o",
                      "--out",
                      dest="filename",
                      default="out.jpg",
                      help="The filename you want your final image saved as")
    parser.add_option("-w",
                      "--words",
                      dest="words",
                      default="#",
                      help="Use words to create your image")
    parser.add_option("-s",
                      "--step",
                      dest="step",
                      type="int",
                      default=3,
                      help="Choose the distance of your characters")
    parser.add_option(
        "-d",
        "--density",
        action="store_true",
        dest='density',
        help="Adding the flag converts the image based on visual density")
    parser.add_option("-t",
                      "--terminal",
                      action="store_true",
                      dest='terminal',
                      help="Print ascii image to terminal")

    (options, args) = parser.parse_args()

    if len(args) > 0:
        in_file = args[0]
    else:
        print("Failed to provide an input image")
        return

    a = Ascii(in_file)

    if options.density:
        a.density_artify(step=options.step)
        a.save(options.filename)

    elif options.terminal:
        a.terminal_artify()

    else:
        a.word_artify(options.words, options.step)
        a.save(options.filename)