#!/usr/bin/python # -*- coding: utf-8 -*- # Japanese ASCII-Art load script for GIMP # Copyright (C) 2011 Jun Kobayashi # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # Usage: # gimp --console-messages --no-data --no-splash --batch-interpreter python-fu-eval --batch - < gimp-load-aa.py import sys import os from gimpfu import * image = pdb.gimp_image_new(10, 10, RGB) filename = os.environ["HOME"] + '/aa.txt' f = open(filename) text = f.read() f.close white_back = pdb.gimp_layer_new(image, 10, 10, RGB_IMAGE, "白背景", 100, 0) pdb.gimp_image_add_layer(image, white_back, 0) pdb.gimp_context_set_background((255, 255, 255)) pdb.gimp_context_set_foreground((0, 0, 0)) pdb.gimp_drawable_fill(white_back, BACKGROUND_FILL) #pdb.gimp_layer_add_alpha(white_back) layer = pdb.gimp_layer_new(image, 10, 10, RGB_IMAGE, "アスキーアート", 100, 0) pdb.gimp_image_add_layer(image, layer, 0) pdb.gimp_drawable_fill(layer, BACKGROUND_FILL) #pdb.gimp_layer_add_alpha(layer) text_layer = pdb.gimp_text_fontname(image, layer, 0, 0, text, 0, TRUE, 16, PIXELS, "IPA モナー Pゴシック") w = pdb.gimp_drawable_width(text_layer) + 32 h = pdb.gimp_drawable_height(text_layer) + 32 pdb.gimp_layer_resize(layer, w, h, 0, 0) pdb.gimp_layer_resize(white_back, w, h, 0, 0) pdb.gimp_layer_set_offsets(text_layer, 16, 16) pdb.gimp_floating_sel_anchor(text_layer) pdb.gimp_image_resize(image, w, h, 0, 0) pdb.gimp_display_new(image)