Academic Tutorials



English | French | Portugese | German | Italian
Home Advertise Payments Recommended Websites Interview Questions FAQs
News Source Codes E-Books Downloads Jobs Web Hosting
Chats

Gimp Tutorial
Gimp Introduction
Gimp Background
GIMP PDB
Gimp Object Oriented Syntax
Gimp Painting Areas
Gimp Creating Text
Gimp Floating Selections
Gimp Perl Server

HTML Tutorials
HTML Tutorial
XHTML Tutorial
CSS Tutorial
TCP/IP Tutorial
CSS 1.0
CSS 2.0
HLML
XML Tutorials
XML Tutorial
XSL Tutorial
XSLT Tutorial
DTD Tutorial
Schema Tutorial
XForms Tutorial
XSL-FO Tutorial
XML DOM Tutorial
XLink Tutorial
XQuery Tutorial
XPath Tutorial
XPointer Tutorial
RDF Tutorial
SOAP Tutorial
WSDL Tutorial
RSS Tutorial
WAP Tutorial
Web Services Tutorial
Browser Scripting
JavaScript Tutorial
VBScript Tutorial
DHTML Tutorial
HTML DOM Tutorial
WMLScript Tutorial
E4X Tutorial
Server Scripting
ASP Tutorial
PERL Tutorial
SQL Tutorial
ADO Tutorial
CVS
Python
Apple Script
PL/SQL Tutorial
SQL Server
PHP
.NET (dotnet)
Microsoft.Net
ASP.Net
.Net Mobile
C# : C Sharp
ADO.NET
VB.NET
VC++
Multimedia
SVG Tutorial
Flash Tutorial
Media Tutorial
SMIL Tutorial
Photoshop Tutorial
Gimp Tutorial
Matlab
Gnuplot Programming
GIF Animation Tutorial
Scientific Visualization Tutorial
Graphics
Web Building
Web Browsers
Web Hosting
W3C Tutorial
Web Building
Web Quality
Web Semantic
Web Careers
Weblogic Tutorial
SEO
Web Site Hosting
Domain Name
Java Tutorials
Java Tutorial
JSP Tutorial
Servlets Tutorial
Struts Tutorial
EJB Tutorial
JMS Tutorial
JMX Tutorial
Eclipse
J2ME
JBOSS
Programming Langauges
C Tutorial
C++ Tutorial
Visual Basic Tutorial
Data Structures Using C
Cobol
Assembly Language
Mainframe
Forth Programming
Lisp Programming
Pascal
Delphi
Fortran
OOPs
Data Warehousing
CGI Programming
Emacs Tutorial
Gnome
ILU
Soft Skills
Communication Skills
Time Management
Project Management
Team Work
Leadership Skills
Corporate Communication
Negotiation Skills
Database Tutorials
Oracle
MySQL
Operating System
BSD
Symbian
Unix
Internet
IP-Masquerading
IPC
MIDI
Software Testing
Testing
Firewalls
SAP Module
ERP
ABAP
Business Warehousing
SAP Basis
Material Management
Sales & Distribution
Human Resource
Netweaver
Customer Relationship Management
Production and Planning
Networking Programming
Corba Tutorial
Networking Tutorial
Microsoft Office
Microsoft Word
Microsoft Outlook
Microsoft PowerPoint
Microsoft Publisher
Microsoft Excel
Microsoft Front Page
Microsoft InfoPath
Microsoft Access
Accounting
Financial Accounting
Managerial Accounting
Network Sites


Creating text


Previoushome Next






. Creating text


7.1. Hello World - writing text in an image


To create text the PDB function gimp_text_fontname() may be used. In this function the font is specified in the X11 font conventions.

A D V E R T I S E M E N T
(There are also some older functions, gimp_text and gimp_text_ext in which the different X11 fields are specified explicitely.)

Here is an example of a script that creates an image containing "Hello world".

hello-world1
  1:  #!/usr/local/bin/perl 
  2:   
  3:  use Gimp ":auto"; 
  4:  use Gimp::Fu; 
  5:   
  6:  sub text1 { 
  7:      my($font, $text) = @_; 
  8:       
  9:      # Create a new image 
 10:      $img = gimp_image_new(350, 100, RGB); 
 11:   
 12:      # Create a new layer and draw it to the image at the top 
 13:      $drw = gimp_layer_new($img, $img->width, $img->height, 
 14:  			  RGB, "BG", 100, NORMAL_MODE); 
 15:      $drw->add_layer(-1); 
 16:      gimp_palette_set_background("black"); 
 17:      gimp_edit_fill($drw, BG_IMAGE_FILL); 
 18:   
 19:   
 20:      # Choose color of text 
 21:      gimp_palette_set_foreground([255,255,0]); 
 22:   
 23:      # Create the text 
 24:      my $border = 10; 
 25:      my $text_layer = gimp_text_fontname($drw,  0, 0, $text, 
 26:  					$border, 1,  
 27:  					xlfd_size($font), $font); 
 28:      gimp_floating_sel_anchor($text_layer); 
 29:       
 30:      return $img; 
 31:  } 
 32:   
 33:  # register the script 
 34:  register "hello_world1", "basic text", "basic text", "Dov", "Dov", 
 35:      "1999-05-14", 
 36:      "<Toolbox>/Xtns/Perl-Fu/Tutorial/Basic text 1",  
 37:      "*", 
 38:      [ 
 39:       [PF_FONT, "font", "font", "-*-utopia-bold-r-*-*-70-*-*-*-*-*-*-*"], 
 40:       [PF_STRING, "text", "text", "Hello world!"] 
 41:      ], 
 42:      \&text1; 
 43:   
 44:  # Handle over control to gimp 
 45:  exit main(); 


The result:  

The script makes use of the function xlfd_size which extracts the size of the font from the X11 font name. This is necessary as the authors of gimp_text_fontname decided that the font size within the fontname is ignored.

One thing to note in this script is that the text that is created on line 24 is a

floating layer, than needs to be anchored to its parent layer. This is done in line 27 through the call to gimp_floating_sel_anchor().

This script suffers from the problem that the image size is unrelated to the text size. This is taken care of in the following more complex example which shows the basic steps for a logo generating script.

  • Creation of an image arbitrary size
  • Creation of a background drawable of an arbitrary size
  • Creation of text layer which exactly fits the text with the command gimp_text_fontname().
  • Resizing the image and the background to the size of the text layer.

The result is an image composed of two layers; a transparent text layer on top of a uniform background.
basic-logo
  1:  #!/usr/local/bin/perl 
  2:   
  3:  use Gimp ":auto"; 
  4:  use Gimp::Fu; 
  5:   
  6:  sub basic_logo { 
  7:      my($font, $border, $text, $bgcolor, $fgcolor) = @_; 
  8:   
  9:      # Create a new image of an arbitrary size with  
 10:      $img = gimp_image_new(100, 100, RGB); 
 11:       
 12:      # Create a new layer for the background of arbitrary size, and 
 13:      # add it to the image 
 14:      my $background = gimp_layer_new($img, 100, 100, 
 15:  				    RGB, "Background", 100, 
 16:  				    NORMAL_MODE); 
 17:      gimp_image_add_layer($background, 1); 
 18:   
 19:      # Choose color of text 
 20:      gimp_palette_set_foreground($fgcolor); 
 21:   
 22:      # Create the text layer. Using -1 as the drawable creates a new layer. 
 23:      my $text_layer = gimp_text_fontname($img, -1, 0, 0, $text, 
 24:  					$border, 1, xlfd_size($font), $font); 
 25:   
 26:      # Get size of the text drawable and resize the image and the 
 27:      # background layer to this size. 
 28:      my($width, $height) = ($text_layer->width, $text_layer->height); 
 29:      gimp_image_resize($img, $width, $height, 0, 0); 
 30:      gimp_layer_resize($background, $width, $height, 0, 0); 
 31:   
 32:      # Fill the background layer now when it has the right size. 
 33:      gimp_palette_set_background($bgcolor); 
 34:      gimp_edit_fill($background, BG_IMAGE_FILL); 
 35:       
 36:      return $img; 
 37:  } 
 38:   
 39:  # register the script 
 40:  register "basic_logo", "basic logo", "basic logo", 
 41:      "Dov Grobgeld", "Dov Grobgeld", 
 42:      "1999-06-09", 
 43:      "<Toolbox>/Xtns/Perl-Fu/Tutorial/Basic Logo",  
 44:      "*", 
 45:      [ 
 46:       [PF_FONT,   "font",     "font",   "-*-utopia-bold-r-*-*-70-*-*-*-*-*-*-*"], 
 47:       [PF_INT,    "border",   "border", "10"], 
 48:       [PF_STRING, "text",     "text", "Hello world!"], 
 49:       [PF_COLOR,  "bg_color", "Background color", [40,180,160]], 
 50:       [PF_COLOR,  "fg_color", "Background color", [255,255,0]], 
 51:      ], 
 52:      \&basic_logo; 
 53:   
 54:  # Handle over control to gimp 
 55:  exit main(); 


Note the special syntax of gimp_image_text_fontname() in line 23 in basic-logo with an image specified for a first parameter, and the drawable = -1. This is in contradiction to the rule above that the image should not be specified for PDB functions that take both an image and a drawable as the first two parameters. But since the drawable=-1, which has no image related to it, an image explicitely be provided. The special case drawable=-1 means that instead of creating a floating layer, a new image layer will be created.

The result shown in the following dialog and the resulting image:

 




Be the first one to comment on this page.




  Gimp Tutorial eBooks

No eBooks on Gimp could be found as of now.

 
 Gimp Tutorial FAQs
More Links » »
 
 Gimp Tutorial Interview Questions

No Gimp Interview Questions could be found as of now.

 
 Gimp Tutorial Articles

No Gimp Articles could be found as of now.

 
 Gimp Tutorial News

No News on Gimp could be found as of now.

 
 Gimp Tutorial Jobs

No Gimp Articles could be found as of now.


Share And Enjoy:These icons link to social bookmarking sites where readers can share and discover new web pages.
  • blinkbits
  • BlinkList
  • blogmarks
  • co.mments
  • connotea
  • del.icio.us
  • De.lirio.us
  • digg
  • Fark
  • feedmelinks
  • Furl
  • LinkaGoGo
  • Ma.gnolia
  • NewsVine
  • Netvouz
  • RawSugar
  • Reddit
  • scuttle
  • Shadows
  • Simpy
  • Smarking
  • Spurl
  • TailRank
  • Wists
  • YahooMyWeb

Previoushome Next

Keywords: Creating text, GIMP Tutorial, GIMP tutorial pdf, history of GIMP, basic GIMP, syntax use in GIMP, GIMP training courses, GIMP Download.

HTML Quizzes
HTML Quiz
XHTML Quiz
CSS Quiz
TCP/IP Quiz
CSS 1.0 Quiz
CSS 2.0 Quiz
HLML Quiz
XML Quizzes
XML Quiz
XSL Quiz
XSLT Quiz
DTD Quiz
Schema Quiz
XForms Quiz
XSL-FO Quiz
XML DOM Quiz
XLink Quiz
XQuery Quiz
XPath Quiz
XPointer Quiz
RDF Quiz
SOAP Quiz
WSDL Quiz
RSS Quiz
WAP Quiz
Web Services Quiz
Browser Scripting Quizzes
JavaScript Quiz
VBScript Quiz
DHTML Quiz
HTML DOM Quiz
WMLScript Quiz
E4X Quiz
Server Scripting Quizzes
ASP Quiz
PERL Quiz
SQL Quiz
ADO Quiz
CVS Quiz
Python Quiz
Apple Script Quiz
PL/SQL Quiz
SQL Server Quiz
PHP Quiz
.NET (dotnet) Quizzes
Microsoft.Net Quiz
ASP.Net Quiz
.Net Mobile Quiz
C# : C Sharp Quiz
ADO.NET Quiz
VB.NET Quiz
VC++ Quiz
Multimedia Quizzes
SVG Quiz
Flash Quiz
Media Quiz
SMIL Quiz
Photoshop Quiz
Gimp Quiz
Matlab Quiz
Gnuplot Programming Quiz
GIF Animation Quiz
Scientific Visualization Quiz
Graphics Quiz
Web Building Quizzes
Web Browsers Quiz
Web Hosting Quiz
W3C Quiz
Web Building Quiz
Web Quality Quiz
Web Semantic Quiz
Web Careers Quiz
Weblogic Quiz
SEO Quiz
Web Site Hosting Quiz
Domain Name Quiz
Java Quizzes
Java Quiz
JSP Quiz
Servlets Quiz
Struts Quiz
EJB Quiz
JMS Quiz
JMX Quiz
Eclipse Quiz
J2ME Quiz
JBOSS Quiz
Programming Langauges Quizzes
C Quiz
C++ Quiz
Visual Basic Quiz
Data Structures Using C Quiz
Cobol Quiz
Assembly Language Quiz
Mainframe Quiz
Forth Programming Quiz
Lisp Programming Quiz
Pascal Quiz
Delphi Quiz
Fortran Quiz
OOPs Quiz
Data Warehousing Quiz
CGI Programming Quiz
Emacs Quiz
Gnome Quiz
ILU Quiz
Soft Skills Quizzes
Communication Skills Quiz
Time Management Quiz
Project Management Quiz
Team Work Quiz
Leadership Skills Quiz
Corporate Communication Quiz
Negotiation Skills Quiz
Database Quizzes
Oracle Quiz
MySQL Quiz
Operating System Quizzes
BSD Quiz
Symbian Quiz
Unix Quiz
Internet Quiz
IP-Masquerading Quiz
IPC Quiz
MIDI Quiz
Software Testing Quizzes
Testing Quiz
Firewalls Quiz
SAP Module Quizzes
ERP Quiz
ABAP Quiz
Business Warehousing Quiz
SAP Basis Quiz
Material Management Quiz
Sales & Distribution Quiz
Human Resource Quiz
Netweaver Quiz
Customer Relationship Management Quiz
Production and Planning Quiz
Networking Programming Quizzes
Corba Quiz
Networking Quiz
Microsoft Office Quizzes
Microsoft Word Quiz
Microsoft Outlook Quiz
Microsoft PowerPoint Quiz
Microsoft Publisher Quiz
Microsoft Excel Quiz
Microsoft Front Page Quiz
Microsoft InfoPath Quiz
Microsoft Access Quiz
Accounting Quizzes
Financial Accounting Quiz
Managerial Accounting Quiz
Testimonials | Contact Us | Link to Us | Site Map
Copyright 2008. Academic Tutorials.com. All rights reserved Privacy Policies | About Us
Our Portals : Academic Tutorials | Best eBooksworld | Beyond Stats | City Details | Interview Questions | Discussions World | Excellent Mobiles | Free Bangalore | Give Me The Code | Gog Logo | Indian Free Ads | Jobs Assist | New Interview Questions | One Stop FAQs | One Stop GATE | One Stop GRE | One Stop IAS | One Stop MBA | One Stop SAP | One Stop Testing | Webhosting in India | Dedicated Server in India | Sirf Dosti | Source Codes World | Tasty Food | Tech Archive | Testing Interview Questions | Tests World | The Galz | Top Masala | Vyom | Vyom eBooks | Vyom International | Vyom Links | Vyoms | Vyom World
Copyright 2003-2017 Vyom Technosoft Pvt. Ltd., All Rights Reserved.