<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Seventh Sense &#187; Graphics</title>
	<atom:link href="http://sgowtham.net/blog/category/technology/graphics/feed/" rel="self" type="application/rss+xml" />
	<link>http://sgowtham.net/blog</link>
	<description>Rambling about life&#039;s little things, in 7 ≡ 1 (mod 6) fashion</description>
	<lastBuildDate>Tue, 28 Feb 2012 23:25:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<image>
	<title>Seventh Sense</title>
	<url>http://sgowtham.net/images/sg_logo_rss.png</url>
	<link>http://sgowtham.net/blog</link>
	<width>32</width>
	<height>32</height>
	</image>
		<item>
		<title>PHP &#8211; Converting Strings To Images</title>
		<link>http://sgowtham.net/blog/2008/08/16/php-converting-strings-to-images/</link>
		<comments>http://sgowtham.net/blog/2008/08/16/php-converting-strings-to-images/#comments</comments>
		<pubDate>Sat, 16 Aug 2008 20:26:51 +0000</pubDate>
		<dc:creator>Gowtham</dc:creator>
				<category><![CDATA[Graphics]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Showcase]]></category>

		<guid isPermaLink="false">http://sgowtham.net/blog/?p=517</guid>
		<description><![CDATA[One of the most primal needs of displaying strings as an image is during form submission and to make sure that a human being (although there is a finite probability that a monkey can accidentally type the same string correctly) types in the string. This form submission can be to accomplish one of many things [...]]]></description>
			<content:encoded><![CDATA[<p>One of the most primal needs of displaying strings as an image is during form submission and to make sure that a human being (although there is a finite probability that a monkey can accidentally type the same string correctly) types in the string. This form submission can be to accomplish one of many things &#8211; posting comments, placing web orders, displaying email addresses, etc. For my recent, still on-going, attempts to write a personally satisfying <a href="http://sgowtham.net/showcase/" target="_blank">photoblog software/application</a>, I need this as part of comment-submission process.</p>
<p><br clear="all"></p>
<h3 class="blog">Requirements</h3>
<p>It is my practice that I do a full/maximal installation of any linux distribution and that takes care of installing Apache (with all the required modules), PHP, MySQL, ImageMagick, etc. I bet there are tons of documents online that you can refer and install them if you don&#8217;t already have them.</p>
<p><br clear="all"></p>
<h3 class="blog">SecureImage.php</h3>
<p>Let us suppose that all the required code goes into a file called <strong>SecureImage.php</strong>.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Length of security phrase
</span><span style="color: #000088;">$phrase_length</span>   <span style="color: #339933;">=</span> <span style="color: #cc66cc;">6</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$security_phrase</span> <span style="color: #339933;">=</span> SecurityPhrase<span style="color: #009900;">&#40;</span><span style="color: #000088;">$phrase_length</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> SecurityPhrase <span style="color: #009900;">&#40;</span><span style="color: #000088;">$length</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;"># Start with a blank security_phrase
</span>  <span style="color: #000088;">$security_phrase</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;"># Define possible characters
</span>  <span style="color: #666666; font-style: italic;"># Exlude vowels to prevent offensive phrases
</span>  <span style="color: #000088;">$characters</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;0123456789bcdfghjkmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ&quot;</span><span style="color: #339933;">;</span> 
&nbsp;
  <span style="color: #666666; font-style: italic;"># A counter to keep track of number of characters 
</span>  <span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;"># Add random characters to $security_phrase until $length is reached
</span>  <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">&lt;</span> <span style="color: #000088;">$length</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
    <span style="color: #666666; font-style: italic;"># Pick a random character from the possible ones
</span>    <span style="color: #000088;">$character</span> <span style="color: #339933;">=</span> <span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$characters</span><span style="color: #339933;">,</span> <span style="color: #990000;">mt_rand</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #990000;">strlen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$possible</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;"># Avoid repetition of characters
</span>    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">strstr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$security_phrase</span><span style="color: #339933;">,</span> <span style="color: #000088;">$character</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
      <span style="color: #000088;">$security_phrase</span> <span style="color: #339933;">.=</span> <span style="color: #000088;">$character</span><span style="color: #339933;">;</span>
      <span style="color: #000088;">$i</span><span style="color: #339933;">++;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;"># Temporary location to store the image
</span>  <span style="color: #666666; font-style: italic;"># /var/www/html is the default DocumentRoot in Red Hat like distributions
</span>  <span style="color: #666666; font-style: italic;"># The folder, 'tmp' must have read and write permissions for the apache (or the web) user
</span>  <span style="color: #000088;">$tmp_image_location</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;/var/www/html/tmp/&quot;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;"># Filename of the image (PNG)
</span>  <span style="color: #666666; font-style: italic;"># Security Phrase itself will be the filename
</span>  <span style="color: #000088;">$tmp_image_filename</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$tmp_image_location</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$security_phrase</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;.png&quot;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;"># ImageMagick's 'convert' utility and options
</span>  <span style="color: #000088;">$text2img</span>  <span style="color: #339933;">=</span> <span style="color: #0000ff;">'/usr/bin/convert '</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$text2img</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">' -background white '</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$text2img</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">' -fill black '</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$text2img</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">' -pointsize 30 '</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$text2img</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">' -gravity West '</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$text2img</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">' -wave 2x80'</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$text2img</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">' label:'</span><span style="color: #339933;">.</span><span style="color: #000088;">$security_phrase</span><span style="color: #339933;">.</span><span style="color: #0000ff;">' '</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$text2img</span> <span style="color: #339933;">.=</span> <span style="color: #000088;">$tmp_image_filename</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;"># Run the command
</span>  <span style="color: #990000;">system</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$text2img</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;"># Display the image
</span>  <span style="color: #b1b100;">print</span> <span style="color: #0000ff;">&quot;&lt;img src=<span style="color: #000099; font-weight: bold;">\&quot;</span>/tmp/<span style="color: #006699; font-weight: bold;">$security_phrase</span>.png<span style="color: #000099; font-weight: bold;">\&quot;</span> border=<span style="color: #000099; font-weight: bold;">\&quot;</span>0<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;
         &lt;br&gt;&quot;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #b1b100;">return</span> <span style="color: #000088;">$security_phrase</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p><br clear="all"></p>
<h3 class="blog">Using This In A Form</h3>
<p>Let us suppose that the form looks something like following:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
</pre></td><td class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">form</span> <span style="color: #000066;">method</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;POST&quot;</span> <span style="color: #000066;">action</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;APPROPRIATE URL&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">table</span> <span style="color: #000066;">border</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000066;">cellpadding</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;5&quot;</span> <span style="color: #000066;">cellspacing</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;3&quot;</span> <span style="color: #000066;">align</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;center&quot;</span>&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">tr</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">td</span> <span style="color: #000066;">valign</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;top&quot;</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">b</span>&gt;</span>Name<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">b</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">td</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">td</span> <span style="color: #000066;">valign</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;top&quot;</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;name&quot;</span> <span style="color: #000066;">size</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;25&quot;</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">font</span> <span style="color: #000066;">size</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #000066;">color</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#000066&quot;</span>&gt;</span>
  (Required)
  <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">font</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">td</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">tr</span>&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">tr</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">td</span> <span style="color: #000066;">valign</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;top&quot;</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">b</span>&gt;</span>Email<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">b</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">td</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">td</span> <span style="color: #000066;">valign</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;top&quot;</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;email&quot;</span> <span style="color: #000066;">size</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;25&quot;</span>&gt;</span> 
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">font</span> <span style="color: #000066;">size</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #000066;">color</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#000066&quot;</span>&gt;</span>
  (Required; must be valid; will not be shared or made public)
  <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">font</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">td</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">tr</span>&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">tr</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">td</span> <span style="color: #000066;">valign</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;top&quot;</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">b</span>&gt;</span>URL<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">b</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">td</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">td</span> <span style="color: #000066;">valign</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;top&quot;</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;url&quot;</span> <span style="color: #000066;">size</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;25&quot;</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">font</span> <span style="color: #000066;">size</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #000066;">color</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#000066&quot;</span>&gt;</span>
  (Optional; please include http://)
  <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">font</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">td</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">tr</span>&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">tr</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">td</span> <span style="color: #000066;">valign</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;top&quot;</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">b</span>&gt;</span>Security Phrase<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">b</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">td</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">td</span> <span style="color: #000066;">valign</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;top&quot;</span>&gt;</span>
  <span style="color: #009900;">&lt;?php include<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'SecureImage.php'</span><span style="color: #66cc66;">&#41;</span>; ?&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;security_phrase&quot;</span> <span style="color: #000066;">size</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;25&quot;</span>&gt;</span> 
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">font</span> <span style="color: #000066;">size</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #000066;">color</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#000066&quot;</span>&gt;</span>
  (Required; enter the characters shown above)
  <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">font</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">td</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">tr</span>&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">tr</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">td</span> <span style="color: #000066;">valign</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;top&quot;</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">b</span>&gt;</span>Comments<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">b</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">td</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">td</span> <span style="color: #000066;">valign</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;top&quot;</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">textarea</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;comments&quot;</span> <span style="color: #000066;">rows</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;6&quot;</span> <span style="color: #000066;">cols</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;40&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">textarea</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">td</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">tr</span>&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">tr</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">td</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;noborder&quot;</span>&gt;</span>
<span style="color: #ddbb00;">&amp;nbsp;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">td</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">td</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;noborder&quot;</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;submit&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Submit&quot;</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;reset&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Clear&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">td</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">tr</span>&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">table</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">form</span>&gt;</span></pre></td></tr></table></div>

<p><strong>APPROPRIATE URL</strong> refers to perhaps a PHP script that will process the information submitted by this form.</p>
<p><br clear="all"></p>
<h3 class="blog">Screenshot</h3>
<p><img class="framed" src="http://sgowtham.net/blog/files/20080816/SecureImage.png" title="SecureImage" alt="SecureImage" border="0"></p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fsgowtham.net%2Fblog%2F2008%2F08%2F16%2Fphp-converting-strings-to-images%2F&amp;title=PHP%20%26%238211%3B%20Converting%20Strings%20To%20Images" id="wpa2a_2"><img src="http://sgowtham.net/blog/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://sgowtham.net/blog/2008/08/16/php-converting-strings-to-images/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Kannada LaTeX Expressions &#8211; In Graphical Format</title>
		<link>http://sgowtham.net/blog/2008/01/13/kannada-latex-expressions-in-graphical-format/</link>
		<comments>http://sgowtham.net/blog/2008/01/13/kannada-latex-expressions-in-graphical-format/#comments</comments>
		<pubDate>Sun, 13 Jan 2008 18:56:53 +0000</pubDate>
		<dc:creator>Gowtham</dc:creator>
				<category><![CDATA[Graphics]]></category>
		<category><![CDATA[Kannada]]></category>
		<category><![CDATA[LaTeX]]></category>

		<guid isPermaLink="false">http://sgowtham.net/blog/2008/01/13/kannada-latex-expressions-in-graphical-format/</guid>
		<description><![CDATA[Disclaimer Not liking something is NOT THE SAME as hating it. With above point in mind, I do not like MS Word. With first point still in mind, I do not dislike and/or hate people who like and/or use MS Word. I LOVE LaTeX &#8211; nerds/geeks don&#8217;t feel like doing something (be it as simple [...]]]></description>
			<content:encoded><![CDATA[<h3 class="blog">Disclaimer</h3>
<ol>
<li><em>Not liking something</em> is NOT THE SAME as <em>hating it</em>.</li>
<li>With above point in mind, I do not like MS Word.</li>
<li>With first point still in mind, I do not dislike and/or hate people who like and/or use MS Word.</li>
<li>I LOVE LaTeX &#8211; nerds/geeks don&#8217;t feel like doing something (be it as simple a task as preparing a document) unless one actually <u>compiles</u> it (and gets error messages for mistakes); and whether you agree with me or not, I am one of them.</li>
</ol>
<p><br clear="all"></p>
<h3 class="blog">KannadaLaTeX</h3>
<p>Leelavati Trust brought out the KannadaLaTeX, using which one can compose LaTeX documents in my native language, Kannada. It comes with a manual for using keyboard and can be used both in Windows and in Linux/UNIX environments. More information can be obtained by contacting Dr. C S Yogananda. There have been quite many attempts (by numerous people) to have typeset Kannada in LaTeX but in my personal opinion and from personal experience, nothing has been as easy as KannadaLaTeX &#8211; both to install (I have only done it on my linux box running Red Hat Enterprise Linux AS 4.4 and other distributions) and use it.</p>
<p>How I got to know/learn about is an interesting story. Those were the days &#8211; way back in 2003-04 I suppose &#8211; when I used to write letters to my parents and I was constantly searching for a tool to typeset Kannada under linux (I had recently been initiated into linux and I was planning on making it The Operating System of choice). Many sleepless nights, weekends went past before I came across KannadaLaTeX on <a href="http://sourceforge.net/" target="_blank">SourceForge</a>. The man behind this project was Dr. C S Yogananda, and his name was quite familiar to me &#8211; through a lecture he gave in <a href="http://en.wikipedia.org/wiki/H._Narasimhaiah" target="_blank">Bangalore Science Forum</a> (in National College Basavanagudi &#8211; titled <em>Prof. Harishchandra &#8211; Physicist Turned Mathematician</em> on 27th July 2000) and through his work/writings in <a href="http://www.ias.ac.in/resonance/" target="_blank">Resonance</a>, published by the <a href="http://en.wikipedia.org/wiki/Indian_Academy_of_Sciences" target="_blank">Indian Academy of Sciences</a>.</p>
<p><br clear="all"></p>
<h3 class="blog">Why KannadaLaTeX?</h3>
<p>It&#8217;s a well known and widely established fact that <em>Equation Editor</em> (used inside MS Office products) does not produce decent looking expressions, especially when they are mathematical in nature. It&#8217;s also a well known and well established fact that the mathematical expressions produced by LaTeX are crisp, elegant and provide the biggest bang for the buck (linux is free, LaTeX is free and all one puts in is some time and effort). There are probably as many reasons to use LaTeX for typesetting Kannada as there are to compose just about any generic document. I have nothing against <a href="http://www.baraha.com/" target="_blank">Baraha</a> (I have used it extensively since its inception and still do sometimes) as a standalone product or as an inclusion in some word processors, but there are few things that match the beauty of LaTeX &#8211; especially when there is mathematics.</p>
<p><a href="http://www.nought.de/tex2im.html" target="_blank">Andreas Reigber</a> wrote a simple, elegant (command line) utility called <strong>TeX2Im</strong> and released it under GPL. I had been using this utility as a commandline tool for several years but mostly to convert mathematical expressions &#8211; to be used in presentations and such. I have also been using this KannadaLaTeX for a variety of different things for quite some time. Several months ago, I modified the <strong>TeX2Im</strong> to include KannadaLaTeX &#8211; and found personally the most satisfying usage of this hack: occasional typesetting of verses from the legendary work of DVG: <a href="http://sgowtham.net/kagga/" target="_blank"><em>Mankutimmana Kagga</em></a>.</p>
<p>Following my recent attempt to <a href="http://sgowtham.net/blog/2007/09/17/latex-expressions-in-graphical-format/" target="_blank">convert LaTeX Expressions into Graphical Format</a> and while reading a friend&#8217;s recent <a href="http://deepgemini.blogspot.com/2008/01/living.html" target="_blank">blog entry</a>, I realized that a similar web-based utility might find some use. Converting Kannada into LaTeX-generated PNG file is pretty simple and straightforward: Just type-in (or paste) the LaTeX code in the form and copy/save the graphic (in PNG format with transparent background) to your computer. For guidelines for transliteration rules in KannadaLaTeX, you may use this <a href="http://sgowtham.net/blog/files/20080113/KannadaLaTeX_TranslitGuide.pdf" target="_blank">PDF Document</a>.</p>
<p><br clear="all"></p>
<h3 class="blog">Screenshot</h3>
<p><img class="framed" src="http://sgowtham.net/blog/files/20080113/KannadaLaTeX.png" title="Kannada LaTeX Expression in Graphical Format" alt="Kannada LaTeX Expression in Graphical Format" border="0"></p>
<p class="bpcaption">Just An Example</p>
<p><br clear="all"><br />
One can get started by accessing <a href="http://sgowtham.net/tools/tex-kan/" target="_blank"><font color="#ff0000">this page</font></a>. I understand that this web-based utility might have some bugs. If you have issues/problems using it and/or need enhancements, please feel free to post your issue/concern/feature-request as a comment in the form below and either me or some other LaTeX user will respond.</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fsgowtham.net%2Fblog%2F2008%2F01%2F13%2Fkannada-latex-expressions-in-graphical-format%2F&amp;title=Kannada%20LaTeX%20Expressions%20%26%238211%3B%20In%20Graphical%20Format" id="wpa2a_4"><img src="http://sgowtham.net/blog/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://sgowtham.net/blog/2008/01/13/kannada-latex-expressions-in-graphical-format/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>LaTeX Expressions &#8211; In Graphical Format</title>
		<link>http://sgowtham.net/blog/2007/09/17/latex-expressions-in-graphical-format/</link>
		<comments>http://sgowtham.net/blog/2007/09/17/latex-expressions-in-graphical-format/#comments</comments>
		<pubDate>Mon, 17 Sep 2007 22:36:58 +0000</pubDate>
		<dc:creator>Gowtham</dc:creator>
				<category><![CDATA[Academia]]></category>
		<category><![CDATA[Graphics]]></category>
		<category><![CDATA[LaTeX]]></category>

		<guid isPermaLink="false">http://sgowtham.net/blog/2007/09/17/latex-expressions-in-graphical-format/</guid>
		<description><![CDATA[Disclaimer #0 Not liking something is NOT THE SAME as hating it. With above point in mind, I do not like MS Word &#8211; reasons for not liking it could actually be another blog entry and I will reserve it for some other day. With first point still in mind, I do not dislike and/or [...]]]></description>
			<content:encoded><![CDATA[<h3 class="blog">Disclaimer #0</h3>
<ol>
<li><em>Not liking something</em> is NOT THE SAME as <em>hating it</em>.</li>
<li>With above point in mind, I do not like MS Word &#8211; reasons for not liking it could actually be another blog entry and I will reserve it for some other day.</li>
<li>With first point still in mind, I do not dislike and/or hate people who like and/or use MS Word.</li>
<li>I LOVE LaTeX &#8211; nerds/geeks don&#8217;t feel like doing something (be it as simple a task as preparing a document) unless one actually <u>compiles</u> it (and gets error messages for mistakes); and whether you agree with me or not, I am one of them.</li>
</ol>
<p><br clear="all"></p>
<h3 class="blog">What Is LaTeX?</h3>
<p>LaTeX is based on Donald E. Knuth&#8217;s TeX typesetting language or certain extensions. LaTeX was first developed in 1985 by Leslie Lamport, and is now being maintained and developed by the <a href="http://www.latex-project.org/latex3.html" target="_blank">LaTeX3 Project</a>. Following <a href="http://en.wikipedia.org/wiki/LaTeX" target="_blank">Wikipedia</a> and other resources, <em>LaTeX is a document preparation system for high-quality typesetting. It is most often used for medium-to-large technical or scientific documents but it can be used for almost any form of publishing.</em></p>
<p>It is widely used by mathematicians, scientists, philosophers, engineers, and scholars in academia and the commercial world, and by others as a primary or intermediate format (e.g. translating DocBook and other XML-based formats to PDF) because of the quality of typesetting achievable by TeX. It offers programmable desktop publishing features and extensive facilities for automating most aspects of typesetting and desktop publishing, including numbering and cross-referencing, tables and figures, page layout and bibliographies.</p>
<p><br clear="all"></p>
<h3 class="blog">Why LaTeX?</h3>
<p>Like I mentioned in the disclaimer, I could very well write a complete entry entailing reasons why one should use LaTeX, but for the completeness sake of this entry, here are a few reasons: To produce even the simplest of documents with section headings, author names, etc. in most typesetting or word-processing systems, the author would have to decide what layout to use, so would select (say) 18pt Times Roman for the title, 12pt Times Italic for the name, and so on. This has two results: authors wasting their time with designs; and a lot of badly designed documents! LaTeX contains features for:</p>
<ol>
<li>Typesetting journal articles, technical reports, books, and slide presentations.</li>
<li>Control over large documents containing sectioning, cross-references, tables and figures.</li>
<li>Typesetting of complex mathematical formulas.</li>
<li>Advanced typesetting of mathematics with AMS-LaTeX.</li>
<li>Automatic generation of bibliographies and indexes.</li>
<li>Multi-lingual typesetting.</li>
<li>Inclusion of artwork, and process or spot colour.</li>
<li>Using PostScript or Metafont fonts.</li>
<li>Accomplishing just about anything, via few hundreds of available packages.</li>
</ol>
<p><br clear="all"></p>
<h3 class="blog">Why LaTeX Expressions in Graphical Format?</h3>
<p>It&#8217;s a well known and widely established fact that <em>Equation Editor</em> (used inside MS Office products) does not produce decent looking expressions, especially when they are mathematical in nature. It&#8217;s also a well known and well established fact that the mathematical expressions produced by LaTeX are crisp, elegant and provide the biggest bang for the buck (linux is free, LaTeX is free and all one puts in is some time and effort). More often than not, folks in academia find themselves in a situation where they need mathematical expressions as part of their presentations. For those relying on MS Powerpoint but do not wish to use <em>Equation Editor</em>, here&#8217;s a solution:</p>
<p><a href="http://www.nought.de/tex2im.html" target="_blank">Andreas Reigber</a> wrote a simple, elegant (command line) utility called <strong>TeX2Im</strong> and released it under GPL. Although I have been using it for few years now and had the idea of webifying it, it wasn&#8217;t until this afternoon that I finally mustered enough courage to do it. Using this web-based utility is pretty simple. Just type-in (or paste) the LaTeX code for any given expression (without <strong>\begin{equation}</strong> and/or <strong>\end{equation}</strong>) in the form and copy/save the graphic (in PNG format with transparent background) to your computer.</p>
<p><br clear="all"></p>
<h3 class="blog">Screenshot</h3>
<p><img class="framed" src="http://sgowtham.net/blog/files/20070917/LaTeX_PNG.png" title="LaTeX Expression in Graphical Format" alt="LaTeX Expression in Graphical Format" border="0"></p>
<p class="bpcaption">Just An Example</p>
<p><br clear="all"><br />
One can get started by accessing <a href="http://sgowtham.net/tools/tex-eqn/" target="_blank"><font color="#ff0000">this page</font></a>.</p>
<p><br clear="all"></p>
<h3 class="blog">Disclaimer #1</h3>
<p>I understand that this web-based utility might have some bugs. If you have issues/problems using it, please feel free to post your issue/concern as a comment in the form below and either me or some other LaTeX user will respond.</p>
<p><br clear="all"></p>
<h3 class="blog">Acknowledgments</h3>
<p>Thanks to Scott and Jon &#8211; for helping out with some PHP related issues as well as almost-unique way of naming generated graphics.</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fsgowtham.net%2Fblog%2F2007%2F09%2F17%2Flatex-expressions-in-graphical-format%2F&amp;title=LaTeX%20Expressions%20%26%238211%3B%20In%20Graphical%20Format" id="wpa2a_6"><img src="http://sgowtham.net/blog/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://sgowtham.net/blog/2007/09/17/latex-expressions-in-graphical-format/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
	</channel>
</rss>

