TMIL Text Manipulation Imaging Language FINAL REPORT Eli Hamburger eh2315 columbia edu Michele Merler mm3233 columbia edu Jimmy Wei jw2553 columbia edu Lin Yang ly2179 columbia edu December 18 2007 Contents 1 White Paper 1 1 1 Introduction 1 1 2 Motivation and Features 2 1 3 Example of Syntax 2 2 Language Tutorial 5 2 1 Introduction 5 2 2 Hello World 5 2 3 A more elaborate example 7 2 4 CATPCHA 9 3 Language Reference Manual 12 3 1 Introduction 12 3 2 Lexical Conventions 12 3 2 1 Identifiers 12 3 2 2 Comments 12 3 2 3 Reserved Keywords 13 3 2 4 Types 13 3 2 5 Constants 15 3 2 6 Special Characters 16 Conversions 16 3 3 1 Float to integer 16 3 3 2 Integer to float 17 3 3 3 Char and integer 17 3 3 4 Bool to integer or char 17 3 3 i 3 3 5 3 4 Char to string 17 3 4 1 Primary expressions 19 3 4 2 Unary operators 20 3 4 3 Arithmetic operators 21 3 4 4 Relational operators 21 3 4 5 Logical operators 23 3 4 6 Assignment Operator 23 3 4 7 Comma 24 3 4 8 Stamp Operator 24 Declarations 24 3 5 1 Variable declaration 24 3 5 2 Array declaration 25 3 5 3 Function declaration 25 Statements 25 3 6 1 Expression Statement 25 3 6 2 Compound Statements 25 3 6 3 Conditional Statement 26 3 6 4 While Statement 26 3 6 5 For Statement 26 3 6 6 Return statement 27 3 7 Scope Rules 27 3 8 Built in Functions 27 3 8 1 Open 27 3 8 2 Create 28 3 8 3 Save 28 3 8 4 Drawline 28 3 8 5 int2string 28 3 8 6 float2string 28 3 8 7 string2int 28 3 8 8 string2float 29 3 8 9 char at 29 Example 29 3 5 3 6 3 9 Expressions and Operators 17 ii 4 Project Plan 4 1 31 Project Progress Control 31 4 1 1 Group Discussion and Planning 31 4 1 2 Development 31 4 1 3 Testing 32 4 2 Roles and Responsibilities 33 4 3 Programming Style 33 4 3 1 ANTLR Code 33 4 3 2 JAVA Code 33 4 4 Project Development Environment 34 4 5 Project Timeline 34 5 Architectural Design 36 5 1 Architectural Overview 36 5 2 The TMIL Lexer 36 5 3 The TMIL Parser 36 5 4 The TMIL Tree Walker 37 5 5 Symbol Table 37 5 6 Code generation 39 5 7 TMIL h 40 6 Test Plan 6 1 42 Overview 42 6 1 1 Test example 1 43 6 1 2 Test example 2 43 6 1 3 Test example 3 43 6 2 Automation 45 6 3 Coverage 47 6 4 Responsibilities 49 7 Lessons Learned 50 7 1 Eli 50 7 2 Michele 50 7 3 Jimmy 51 7 4 Lin 52 iii 8 Appendix 53 iv Chapter 1 White Paper 1 1 Introduction TMIL pronounced TEE mil short for Text Manipulation Imaging Language is a revolutionary high level programming language that allows users to manipulate text programatically on an image and even draw on it Users of the language can generate small programs that can do sophisticated text manipulations on images without having to resort to complicated graphics libraries or painting programs such as Adobe Photoshop Text manipulation has a wide range of applications specifically geared towards web development Some interesting scenarios include Allowing a user of a Content Management System to display text to website users in fonts that users don t have on their computer Allowing a web site template designer to create template that are easily adaptable Allowing users to interactively label specific regions of an image Generating CAPTCHAs an image based challenge response tests used on many web site registration forms Manipulating text on multiple images to create an animation There are image processing libraries available that can manipulate text and draw on images but they are very difficult and cumbersome to use TMIL was designed from the ground up to have a clean and simple syntax so that users can do repetitive and complicated imaging tasks quickly and efficiently 1 1 2 Motivation and Features Our primary motivation for creating TMIL is to create a specific purpose language that is easy enough to enable developers of all backgrounds to use while remaining powerful enough to draw exactly what the programmer wants The Java Paint2D and the GD2 library for C are both powerful but require a lot of effort for even the simplest projects Other command based image editing application such as ImageMagick require fine tinkering of command line arguments in ununderstandable order While the simple MSPaint and expansive Adobe Photoshop offer similar text on image capabilities they require user interaction The TMIL Language offers the developer a way to automatic adding text or drawing to images in a construct that feels natural The specificity of the language also brings with it security Administrators can give free compilation and execution rights for TMIL code and applications knowing the user is limited in his power The user is constraint to editing images and has no access to other parts of the system through TMIL code TMIL uses standard and recognizable constructs such as if statements and while loops The language also supports native objects such as integers and strings as well as standard functions that are normally available for such objects The simple tools give a programmer a lot of manipulation ability TMIL code flow is intuitive allowing developers to lay down text in the code the same way they would think about doing it interactively The user sets the properties of the text such as font font size color etc he she wishes to set on the image and stamps it on The location of the text and even whether or not to rotate the text are all properties of the text object and can be changed anytime until the text is stamped This allows the programmer to do what he she feels most natural Drawing is also easy yet effective since the user can specify the extremes of the line its thickness and color TMIL is flexible The user can create one text object and stamp it onto many images or stamp many text objects sequentially onto a single image Obviously he she can do a combination of both The user can also easily create any composition of lines he she wishes 1 3 Example of Syntax The simple code example described here loads an image and writes text on it at different positions with different colors rotations and fonts It uses all the built in types offered by the language together with some specific functions 2 int i 0 image im open namefileIn png loads image text t t name dog assigns value dog to property string of t t font Arial ttf assigns arial font to t t size 60 assigns a size to t coordinate coor 3 color c c r 255 c g c b …
View Full Document
Unlocking...