My Dominant Hemisphere

The Official Weblog of 'The Basilic Insula'

Archive for the ‘Unix’ Category

How To [Windows/Linux]: OCR On PDFs Using Tesseract and Imagemagick

leave a comment »


via OCReactive@Flickr (CC BY-NC-SA License)

Howdy readers!

Many moons ago, we met and talked about some of the basics of computer programming. Today I’m going to share with you a BASH shell script that I created using publicly available content as I was trying to OCR a couple of PDFs lying on my hard drive.

OCR is short for “Optical Character Recognition”. OCR software contains algorithms that analyze photographs/scanned images of books, articles, etc. (i.e. text matter) and convert them into plain text such that it can be copy/pasted or manipulated in various forms. For more on what OCR does, see here.

PDFs are ubiquitous these days. And although the file format has been opensourced and standardized, what hasn’t is the way people create PDFs. This gives rise to a plethora of unexpected differences such that two people could create a PDF file from the same input and yet come out with totally different looking PDFs. A lot of this has to do with differences in the way the metadata, layout information, text-layer, embedded fonts, reflow properties, etc. have been stored in the PDF file. For across-the-board accessibility (by people using mobile phones, eReaders, etc.) getting all of these right is absolutely essential.

Sadly, many PDFs of eBooks available online (such as at lack these properties and thus can be a pain to read on small screens. One of the most frequent of problems is that often these PDFs are merely a collection of scanned images of books and articles. And aren’t amenable to note taking, highlighting text, or copy/pasting text, etc. This is where OCR comes into play. Using OCR software one ends up with a file containing text that can then be manipulated to one’s liking. OCR software will obviously omit any pictures or illustrations in its output.

This how-to has been tested on Windows Vista Basic and uses free and open-source software. The script will also work on a Linux system.

  1. Download and install Cygwin from here. Cygwin provides a Linux-like environment on the Windows platform. The default shell that it comes with is BASH. As compared to DOS on Windows, BASH provides a saner way to create tiny programs that can automate tasks. The commands are easier to read and understand.
  2. Run Cygwin and check the output of:
    echo $TERM

    If it says "dumb", then you’re faced with a well-known bug in the installation that doesn’t allow Cygwin to behave properly. To remedy this:

    1. Exit Cygwin.
    2. Click on the Start Menu.
    3. In the field that says “Start Search”, type “Run” and then hit ENTER.
    4. Type sysdm.cpl in the dialogue box that opens.
    5. You are now in the Sytem Properties window. Click on the tab that says “Advanced”. Then click on “Environment Variables”.  Under “System Variables” scroll down to and click on the entry that says “TERM” and click on the “Edit” button at the bottom.
    6. In the box that opens, delete whatever is under “Variable Name” and type cygwin.
    7. Click OK and close the box. Then Click OK and close the “System Properties” box.
    8. Open Cygwin again and see that the output of echo $TERM give you cygwin as the answer.
  3. We’ll need to install a few packages on Cygwin. Install the nano package. Nano is an easy to use text-editor and is more reliable than lame-old Notepad. Notepad can sometimes misbehave and enter invisible control-characters (such as carriage-returns or end-of-files) that Linux systems WILL NOT ignore.
  4. Install the tesseract-ocr, tesseract-ocr-eng, imagemagick and ghostscript packages. Tesseract is the OCR software we shall be using. It works best with English text and supposedly has a reputation for being more accurate than other open-source tools out there. Imagemagick is a set of software tools that allow image manipulation using the command-line. Ghostscript is software that Imagemagick will require in order to work with PDFs.
  5. Open Cygwin. Right click on the title bar of the window and goto Properties. Check (tick-mark) the boxes that say “QuickEdit Mode” and “Insert Mode“. Hit OK. Ignore any error messages that pop-up.
  6. Using nano we will create a BASH script called . This will need to be placed or copied to the directory that contains the PDF file that needs to be OCR’d. Type the following text out manually (exactly as it is) or just copy paste it into nano. After copying text from here, when you right-click inside Cygwin, the text will be pasted inside the window. To save the file hit Ctrl-O. Then hit ENTER. Then exit nano by hitting Ctrl-X.

    Using nano to create a file on Cygwin

    Inside nano

    # Created by Firas MR.
    # Website:
    # define variables
    SCRIPT_NAME=`basename "$0" .sh`
    # make a temporary directory
    mkdir $TMP_DIR
    # copy PDF to temporary directory
    cp $@ $TMP_DIR
    # change current working directory to temporary directory
    cd $TMP_DIR
    # use Imagemagick tool to read PDF pages at a pixel denisty of
    # 150 ppi in greyscale mode and output TIFF files at a pixel
    # depth of 8. Tesseract will misbehave with pixel depth > 8
    # or with color images.
    convert -density 150 -depth 8 -colorspace gray -verbose * p%02d.tif
    # For every TIFF file listed in numerical order in the temporary
    # directory (contd)
    for i in `ls *.tif | sort -tp -k2n`;
    # strip away full path to file and file extension
     BASE=`basename "$i" .tif`;
    # run Tesseract using the English language on each TIFF file
     tesseract "${BASE}.tif" "${BASE}" -l eng;
    # append output of each resulting TXT file into an output file with
    # pagebreak marks at then end of each page
     cat ${BASE}.txt | tee -a $OUTPUT_FILE;
     echo "[pagebreak]" | tee -a $OUTPUT_FILE;
    # remove all TIFF and TXT files
     rm ${BASE}.*;
    # move output file to parent directory
    mv $OUTPUT_FILE ..
    # remove any remaining files (eg. PDF, etc.)
    rm *
    # change to parent directory
    cd ..
    # remove temporary directory
    rmdir $TMP_DIR
  7. Next we’ll need to make the file executable by all users. To do this type
    chmod a+x

    and hit ENTER.

  8. Change directories to where the PDF file is located. Eg: in order to change directories to the C: drive in Cygwin you need to do:
    cd /cygdrive/c/

    List contents by typing

    ls -al

    Copy to the directory that contains your PDF. Do this by typing

    cp ~/ .

    (That dot is not a typo!). Rename the PDF to a simple name without hyphens or weird characters. Make it something like bookforocr.pdf . You can do this by typing

    mv <name of PDF file> bookforocr.pdf
  9. Type ./ bookforocr.pdf and observe as your computer chugs away 🙂 ! You’ll end up with a file called ocr-output.txt containing the OCR’d data from the book! Imagemagick will use up quite a bit of RAM memory as it works on the PDF. Expect some sluggishness in your computer as it does this.
  10. You can convert the txt file into anything you like. For example an EPUB file using Calibre that can then be uploaded to an eReader such as the B&N NOOK :-).

One could modify the script to crop, set white-points, etc. for anything fancier. For Windows users who like a GUI, a good open-source cropping tool for PDFs is BRISS. It is a great boon for easily cropping multi-column text matter. Another great tool for the same purpose is Papercrop (although, since it rasterizes its output you notice a significant decrease in quality).

A Linux Journal article describes how to find out position co-ordinates for cropping using GIMP.

Another way that I discovered to OCR a PDF is to use OCRopus. It claims to have automatic and intelligent layout analysis for dealing with stuff like multiple columns, etc.

Alrighty then. See you next time! Feel the OCR power on your PDFs 🙂 !

# Footnotes:

Ubuntuforums Howto on OCR How to OCR multipage PDF files
The Kizz Notes: cygwin: WARNING: terminal is not fully functional

Copyright Firas MR. All Rights Reserved.

“A mote of dust, suspended in a sunbeam.”

Search Blog For Tags: , , , , ,

Written by Firas MR

March 20, 2011 at 8:58 am

Posted in Technology, Unix

Tagged with , ,

What Makes FreeBSD Interesting

with 4 comments

A Narrative History of BSD, by Dr. Kirk McKusick (Courtesy: bsdconferences channel @ Youtube)

Oh Lord, won’t you buy me a 4BSD?
My friends all got sources, so why can’t I see?
Come all you moby hackers, come sing it out with me:
To hell with the lawyers from AT&T!

— a random, hilarious fortune cookie touching on the origins of the FreeBSD project

Howdy all!

Another quick post about tech stuff today. Someday I’ll delve into FreeBSD in a lot more detail. But for now, a brief rundown of why I personally think FreeBSD is one of the best toys around to play with today:

  1. Great documentation! Aside from the FreeBSD Handbook, there are two other books that I think do a phenomenal job in teaching not just the way things are done in the BSD world, but also UNIX philosophy in general. Michael Lucas’s, ‘Absolute FreeBSD‘ and Greg Lehey’s, ‘The Complete FreeBSD‘. My personal all time favorite tech book is currently, ‘The Complete FreeBSD‘. Note the emphasis on ‘all time’. That kind of thing doesn’t come easily from a person who’s not a professional techie. Although Greg ‘Groggy’ Lehey (as he’s popularly known) hasn’t covered the latest version of FreeBSD, a lot of the knowledge you gain from reading his book is pretty transferable. This book also teaches you how computing all began. From the origins of the word ‘Terminal’, to the Hayes command set (he even teaches you some basic commands to talk directly to your modem!), to how the Internet came to be shaped with TCP/IP and BIND and so on. Go check it out for free here and listen to Lehey and Lucas as they are interviewed by BSDTalk here and here. If you’ve ever dabbled in the Linux world, you’ll soon come to realize that FreeBSD’s approach in consolidating, streamlining and simplifying documentation is like a breath of fresh air! Oh and by the way, Dru Lavigne, another famous personality in the BSD world has a great talk on the similarities and differences between BSD and Linux here.
  2. Another incredible boon is their hardware compatibility list (a.k.a. the ‘Hardware Notes‘, that come with every release). It’s jaw-droppingly amazing that you are presented with a list of all known chips/circuit boards and the drivers that you’ll need to use to get them working all organized in such a neat manner right on their main website! Again, something that will definitely blow you away if you’re coming from the Linux world. In fact, when anybody asks me what hardware I recommend for good open-source support (i.e. cross-compatibility across major Operating Systems), I usually turn to this excellent list. It’s a great shopper’s guide! 🙂
  3. From my experience, it’s a lot easier to grasp fundamental concepts about the way computers work by reading about FreeBSD than by looking at books about Linux. In fact Arch Linux, which is a great Linux distribution that I recommend if you want to explore how Linux works, borrows a lot from the manner FreeBSD functions (its /etc/rc.conf file for example) as part of its KISS (Keep It Simple Stupid) philosophy.

More on FreeBSD later! That does it for today! Cheers! 🙂

Copyright © Firas MR. All rights reserved.

, , , , ,

Powered by ScribeFire.

Written by Firas MR

October 25, 2010 at 7:04 pm

Posted in Technology, Unix

Tagged with , , , , ,

Beginning Programming In Plain English

with 3 comments

Part 1 of an introductory series on programming using the Python language via SciPy @ Special Thanks

Before I begin today’s discussion (since it concerns another book), a quick plug for Steve McCurry, whose photography I deeply admire and whose recent photo-essays on the subject of reading, are especially inspirational and worth checking out. I quote:

Fusion: The Synergy of Images and Words Part III « Steve McCurry’s Blog

“Reading is a means of thinking with another person’s mind; it forces you to stretch your own.” — Charles Scribner

Susan Sontag said: “The camera makes everyone a tourist in other people’s reality.” The same can be said for reading books.

Every once in a while, I receive feedback from readers as to how much they appreciate some of my writing on non-clinical/non-medical subjects. Sometimes, the subject matter concerns books or web resources that I’ve recently read. Occasionally, I also like taking notes as I happen to read this material. And often, friends, family and colleagues ask me questions on topics that I’ve either read a book about or have made notes on. Note-taking is a good habit as you grow your comprehension of things. In my opinion, it also helps you skeletonize reading material – sort of like building a quick ‘Table Of Contents’ – that you can utilize to build your knowledge base as you assimilate more and more.

If you’ve ever visited a college bookstore in India, you’ll find dozens and dozens of what are popularly referred to as “guides” or “guidebooks”. These contain summaries and notes on all kinds of subjects – from medicine to engineering and beyond. They help students:

  1. Get verbosity in their main coursebooks (often written in English that is more befitting the Middle Ages) out of the way to focus on skeletonizing material
  2. Cram before exams

I tend to think of my notes and summaries of recently-read books, as guidebooks. Anchor points, that I (& often family or friends) can come back to later on, sometimes when I’ve long forgotten a lot of the material!

I write this summary in this spirit. So with all of that behind us, let’s begin.

I stumbled upon an enticing little book recently, called “Learning the BASH shell“, by Cameron Newham & Bill Rosenblatt. Being the technophile that I am, I just couldn’t resist taking a peek.

I’ve always been fascinated by the innards of computers – from how they’re made and assembled to how they are programmed and used. My first real foray into them began with learning some of the fundamentals of DOS and BASIC on an old 286 (I think) as a 7th grader. Those were the days of pizza-box styled CPU-case form factors, monochrome monitors that had a switch that would turn text green, hard disks that were in the MB range, RAM that was measured in KB and when people thought 3.5 inch floppies were cool. Oh boy, I still do remember the way people used to go gaga over double-sided, high-density, pre-formatted and stuff! As I witnessed the emergence of CDs and then later DVDs and now SSDs and portable HDs, I got my hands dirty on the 386, the 486, the Pentium 1, the Pentium 3, the Pentium 4 (still working!) and my current main workstation which is a Core 2 Duo. Boy, have I come a long way! Over the years I’ve read a number of books on computer hardware (this one and this one recently – more on them for a future post) and software applications and Operating Systems (such as this one on GIMP, this one on GPG, this one, this one and this one on Linux and this one and this one on FreeBSD – again, more on them later!). But there was always one cranny that seemed far too daunting to approach. Yup, programming. Utterly jargoned, the world of modern programming has seemed really quite esoteric & complicated to me from the old days, when BASIC and dBASE could get your plate full. When you’ve lost >95% of your memory on BASIC, it doesn’t help either. Ever since reading about computational biology or bioinformatics (see my summary of a book on the topic here), I’ve been convinced that getting at least a superficial handle on computer programming concepts can mean a lot in terms of having a competitive edge if you ever contemplate being in the research world. This interplay between technology and biology and the level to which our research has evolved over the past few decades was further reinforced by something I read recently from an interview of Kary Mullis, the inventor of PCR. He eventually won the Nobel Prize for his work:

Edge: Eat Me Before I Eat You! A New Foe For The Bad Bugs, A Talk with Kary Mullis


What I do personally is the research, which I can do from home because of the Internet, which pleases me immensely. I don’t need to go to a library; I don’t need to even talk to people face to face.


There are now whole books and articles geared towards programming and biology. I recommend the great introductory essay, Why Biologists Want to Program Computers by author, James Tisdall.

“Learning the BASH shell” is a fascinating newbie-friendly introduction to the world of programming and assumes extremely rudimentary familiarity with how computers work or computer programming in general. It certainly helps if you have a working understanding of Linux or any one of the Unix operating system flavors, but if you’re on Windows you can get by using Cygwin. I’ve been using Linux for the last couple of years (originally beginning with Ubuntu 6.06, then Arch Linux and Debian, Debian being my current favorite), so this background certainly helped me grasp some of the core concepts much faster.

Defining Programming

So what exactly is programming anyway? Well, think of programming as a means to talk to your computer to carry out tasks. Deep down, computers understand nothing but the binary number system (eg: copy this file from here to there translates into gibberish like .…010001100001111000100110…). Not something that most humans would find even remotely appealing (apparently some geeks’ favorite pastime is reverse-engineering human-friendly language from binary!). Now most of us are familiar with using a mouse to point-and-click our way to getting tasks done. But sometimes it becomes necessary to speak to our computers in more direct terms. This ultimately comes down to entering a ‘programming environment’, typing words in a special syntax (depending on what programming language you use) using this environment, saving these words in a file and then translating the file and the words it contains into language the computer can understand (binary language). The computer then executes tasks according to the words you typed. Most languages can broadly be divided into:

  1. Compiler-based: Words in the programming language need to be converted into binary using a program called a ‘compiler’. The binary file can then be run independently. (eg. the C programming language)
  2. Interpreter-based: Words in the programming language are translated on-the-fly into binary. This on-the-fly conversion occurs by means of an intermediary program called an ‘interpreter’. Because of the additional resources required to run the interpreter program, it can sometimes take a while before your computer understands what exactly it needs to do. (eg. the Perl or Python programming languages)

If you think about it, a lot of the stuff we take for granted is actually similar to programming languages. HTML (the stuff of which most web-pages are made) and LATEX (used to make properly typeset professional-quality documents) are called Text Mark-up Languages. By placing the typed words in your document between various tags (i.e. by ‘marking’ text), you tell your web-browser’s HTML-rendering-engine or your LATEX program’s LATEX-rendering-engine to interpret the document’s layout, etc. in a specific way. It’s all actually similar to interpreter-based programming languages. Javascript, the language that’s used to ask your browser to open up a pop-up, etc. is also pretty similar.

What is BASH?

BASH is first and foremost a ‘shell’. If you’ve ever opened up a Command-Prompt or CLI (Command Line Interface) on Windows (Start Menu > Accessories > Command Prompt), then you’ve seen what a shell looks like. Something that provides a text interface to communicate with the innards of your operating system. We’re used to doing stuff the GUI way (Graphical User Interface), using attractive buttons, windows and graphics. Think of the shell as just an alternative means to talk to your computer. Phone-line vs. paper-mail, if that metaphor helps.

Alright, so we get that BASH provides us with an interface. But what else does it do? Well, BASH is also an interpreted programming language! That is amazing because what this allows you to do, is to use your shell to create programs for repetitive or complicated multi-step tasks. A little segue into Unix philosophy bears merit here. Unix-derivative operating systems, unlike others, basically stress on breaking complicated tasks in to tiny bits. Each bit is to be worked on by a program that specializes in that given component of a task. sort is a Unix program that sorts text. cut snips off a chunk of text from a larger whole. grep is used to find text. sed is used to replace text. The find program is used to find files and directories. And so on. If you need to find a given file, then look for certain text in it, yank out a portion of it, replace part of this chunk, then sort it from ascending to descending order, all you do is combine find, grep, sed, cut and sort using the proper syntax. But what if you didn’t really want to replace text? Then all you do is omit sed from the workflow. See, that’s the power of Unix-based OS(s) like Linux or FreeBSD. Flexibility.

The BASH programming language takes simple text files as its input. Then an interpreter called bash translates the words (commands, etc.) into machine-readable code. It’s really as simple as that. Because BASH stresses on the Unix philosophy, it assumes you’ll need to use the various Unix-type programs to get stuff done. So at the end of the day, a BASH program looks a lot like:

execute the Unix program date
assign the output of date to variable x
if x = 8 AM
then execute these Unix program in this order(find, grep, sed, cut, sort, etc.)

Basic Elements of Programming

In general, programming consists of breaking down complicated tasks into bits using unambiguous language in a standard syntax.

The fundamental idea (using BASH as an example) is to:

  1. Construct variables.
  2. Manipulate variables. Add, subtract, change their text content, etc.
  3. Use Conditions such as if/then (referred to in technobabble as “Flow Control”)
  4. Execute Unix programs based on said Conditions

All it takes to get going is learning the syntax of framing your thoughts. And for some languages this can get hairy.

This explains why some of the most popular programming languages out there try to emulate human language as much as possible in their syntax. And why a popular language such as Perl was in fact developed by a linguist!

This was just a brief and extremely high-level introduction to basic concepts in programming. Do grab yourself a copy and dive in to “Learning the BASH shell” with the aforementioned framework in mind. And before you know it, you’ll soon start putting two and two together and be on your way to developing your own nifty program!

I’m going to end for today with some of the additional excellent learning resources that I’m currently exploring to take my quest further:

  1. Steve Parker’s BASH tutorial (extremely easy to follow along)
  2. Greg’s BASH Guide (another one recommended for absolute noobs)
  3. Learning to Program Using Python – A Tutorial for Hobbyists, Self-Starters, and All Who Want to Learn the Art of Computer Programming by Alan Gauld
  4. How to think like a Computer Scientist – Learning with Python by Jeffrey Elkner, Allen B. Downey, and Chris Meyers

UPDATE 1: If you’re looking for a programming language to begin with and have come down to either Perl or Python, but are finding it difficult to choose one over the other, then I think you’ll find the following article by the famous Open Source Software advocate, Eric S. Raymond, a resourceful read: Why Python?

UPDATE 2: A number of resourceful, science-minded people at SciPy conduct workshops aimed at introducing Python and its applications in science. They have a great collection of introductory videos on Python programming concepts & syntax here. Another group, called FOSSEE, has a number of workshop videos introducing Python programming here. They also have a screencast series on the subject here.

UPDATE 3: has quite a number of useful lecture series and Open Courseware material on learning programming and basic Computer Science concepts. Check out the MIT lecture, “Introduction to Computer Science and Programming” which is specifically designed for students with little to no programming experience. The lecture focuses on Python.

Copyright Firas MR. All rights reserved.

# Player used is Stream Player licensed under the GPL. Special thanks to Panos for helping me get the embedded video to work! Steps I followed to get it working:

  • Download the Stream Player plugin as a zip. Extract it locally. Rename the player.swf file to player-swf.jpg
  • Upload player-swf.jpg to your Media Library. Don’t worry, will not complain since it thinks it’s being given a JPG file!
  • Next insert the gigya shortcode as explained at Panos’ website. I inserted the following between square brackets, [ ] :
  • gigya  src=""  width="512" wmode="transparent" allowFullScreen="true" quality="high"  flashvars="file="

  • Parameters to flashvars are separated by ampersands like flashvars="file=MOVIE URL HERE&image=IMAGE URL HERE". The provider="http" parameter to flashvars states that we would like to enable skipping within the video stream.

لیجئے میرا پہلا اردو زبان میں بلوگ پوسٹ

with 3 comments

اردو ہے جسکا نام، ہم ہی جانتے ہیں داغ، سارے جہاں میں دھوم، ہماری زباں کی ہے ~ داغ

(ایک ضروری بات: اس مضمون کو سہی روپ میں دیکھنے کے لئے آپ ناظرین کو یہ font ڈاونلوڈکرکے اپنے سسٹم پر ڈالنا ہوگا. یہ ایسی font ہے جو خاص کمپیوٹر سکرین پر باآسانی پڑھنے کے لئے بنائی گئی ہے.)

آداب دوستو،

امید ہے کہ آپ لوگوں کو میری جانب سے کافی عرصے سے کچھ نہ سننے پر زیادہ شکایات نہیں ہوگی. دراصل بات یہ ہے کہ ہمیشہ کی طرح پڑھائی اور دیگر تعلیمی دنیا سے متعلق چیزوں نے مجھے کافی مصروف رکھا ہے.

میری ہمیشہ سے یہ خواہش تھی کہ کسی دن میں اپنے اس بلوگ پر اردو زبان میں بھی لکھوں. کیونکہ یہ تو میری مادری زبان ہے ہی اور پتہ نہیں کب اور کیسے میرا اس خوبصورت زبان سے رابطہ کچھ ٹوٹنے سا لگا تھا. شاید اس کا قصور میری سائنسی دنیا کا ہے، جو آج کل کے زمانے میں، انگریزی زبان پر ہی زور دیتی ہے. اور اگر اخبارات اور خبروں کی بات کی جائے تو مجھے کبھی یہ نہیں محسوس ہوا کہ اردو دنیا میں کوئی خاص کر انوکھی جیسی چیز ہو. لیکن اب مجھے لگتا ہے کہ میری یہ سوچ کتنی معصوم تھی. پچھلے کچھ ہفتوں سے میرے سامنے کئی ایسی مضامین آے ہیں جو انتہائی دلچسپ ہیں اور جو انگریزی زبان کی دنیا میں شاید ہی دیکھنے کو ملیںگے. یوں سمجھئے کہ مجھے اس زبان سے واقف ہونے کا مزہ آخر اب ہی مل رہا ہے. اور میں اس کے لئے کافی شکرگزار محسوس کر رہا ہوں.

آج کے لئے میرے پاس کسی خاص عنوان پر لکھنے کا رجحان تو نہیں. بس اتنا بتانا چاہتا ہوں کہ انٹرنیٹ پر اردو میں لکھنے کے لئے بہت سارے مددگار سائٹس ہیں. چاہے وہ Linux, BSD, FOSS سے متعلق ہوں یا پھر Windows سے. ان میں سے کچھ جو مجھے بہترین لگے، یہ ہیں:


  • اگر آپ کو لگتا ہے کہ آپ کا اردو ذخیرہ الفاظ کمزور ہے، تو یہ سائٹ آپ کو مدد کرے گی:
  • اگر آپ Windows پر ہوں، تو Google Transliteration IME Keyboard ضرور استعمال کریں. فی الحال یہ صرف Windows کے لیے ہی فراہم ہو رہا ہے :
  • Urdu Fonts ڈاونلوڈ کرکے انکا استعمال Openoffice, Firefox, etc میں کریں. بعض Fonts صرف Windows کے لئے خاص پروگرام کی ہوتی ہیں اور یہ Linux, BSD, etc پر نہیں چلینگی. Windows کے لئے بہترین Fonts آپ کو یہاں سے ملیں گی: . اگر آپ Debian جیسے Linux flavor پر ہیں تو apt-get کا استعمال کریں. CRULP وغیرہ کی جانب 3rd-party fonts کو اس ترکیب سے اپنے سسٹم پر ڈالیے: . واضح رہے کہ جس طرح انگریزی میں الگ الگ Fonts الگ الگ مسائل کے پیش نظر کام آتی ہیں، اسی طرح اردو میں بھی مختلف Fonts ہوتی ہیں جو الگ الگ قلمی انداز میں لکھی جاتی ہیں جیسے نستعلیق، نسخ وغیرہ اور کہیں ایک قسم کی font مناصب ہوگی تو وہیں پر دوسری نامناصب. ان پر بڑھی ہی عمدہ مضامین یہاں ہیں: ، ،
  • Linux, BSD وغیرہ پر SCIM اور IBus جیسی سہولتیں ملیں گی. ان کے ذرے آپ transliteration keyboards کا استعمال کر سکتے ہیں: , . اردو میں لکھنے کے لئے آپ کو m17 packages install کرنا پڑیگا. اور یے بھی مت بھولیے کہ آپ کو اردو زبان کی locales بھی سسٹم پر ڈالنی پڑےنگی. خاص طور پر جو UTF-8 والی ہوں.
  • Firefox کے لئے اردو لغت کو install کرنے کے لئے پہلے Nightly Tester Tools addon install  کیجئے اور پھر Urdu Dictionary addon install کریے.
  • Debian وغیرہ میں کچھ دیگر ترتیبات کے بعد ہی Firefox اردو الفاظ کو سہی ڈھنگ سے دکھاتا ہے. دراصل Debian میں Firefox, Pango font rendering engine کا استعمال بند ہوتا ہے جس کی وجہ سے اردو کے الفاظ ٹھیک نہیں نظر آتے. Pango کو واپس لانے کے لئے ترکیب یہاں ہے:
  • Firefox اور Debian کو لیکر مجھے یے بھی مسلہ کا سامنا کرنا پڑا. ویسے اسکا حل مجھے ابھی تک تو نہیں ملا ہے.
  • Openoffice کے لئے اردو لغت یہاں ملے گی: . اسے اپنے سسٹم پر ڈالنے کے بعد آپ کو Tools>Options>Language Settings میں جا کر Enabled for complex text layout tick-mark کرنا ہوگا. Default زبان کی فہرست میں اردو تو نہیں ہے. تو یہاں پر ہندی ہی رہنے دیجئے. ہوتا یہ ہے کہ جب آپ اردو میں ٹائپ کرنا شروع کرتے ہیں، تو خودبخود Openoffice وثیقہ کی زبان اردو ہے سمجھ جاتا ہے اور اسکا اشارہ bottom toolbar میں کرتا ہے. میرے تجربے میں Debian میں ایسا نہیں ہوتا. آپ کو پہلے اردو میں تھوڑے الفاظ ٹائپ کرنا پڑتا ہے. پھر bottom toolbar کے ذریے زبان کی setting مقرّر کرنی پڑتی  ہے. اچھا، چونکہ ہندی default CTL language ہے، جب آپ اردو ٹائپ کرنے لگتے ہیں، تو ایک ہندی font خودبخود منتخب کی جاتی ہے. جیسے Mangal وغیرہ. تو اس بات کا دھیان رکھتے ہوئے اردو ٹائپ کرتے وقت، اپنی font نسخ، نستعلیق، وغیرہ میں تبدیل کرنا نہ بھولیں.

تو پھر بس آج کے لئے اتنا ہی. امید ہے کہ آپ ناظرین سے پھر ملاقات ہوگی. تب تک کے لئے الوداع!

Copyright Firas MR. All Rights Reserved.

, , ,

Powered by ScribeFire.

Written by Firas MR

October 10, 2010 at 8:25 am

Why The WordPress Visual Editor Doesn’t Work With Konqueror

with 6 comments

Today’s technology tidbits:

The dashboard utilises the TinyMCE javascript visual editor when writing posts in the WYSIWYG format. Unfortunately as stated on its website, TinyMCE isn’t compatible with Konqueror. Why not? Well, here’s a quote from the freshmeat website for TinyMCE:-

…the day Konqueror and Opera implement the Midas specification I will look in to these browsers as target platforms as well…

I’ve noticed one aspect about Konqueror. Developers seem to focus on satisfying W3C standards as their primary goal, leaving the onus on compatibility issues to website and web-based app designers.

Anyhow, I do hope Konqueror and TinyMCE can work together someday soon.

Ubuntu UK’s recent podcast had some very interesting discussion on Linux and security. Nothing’s bullet-proof 🙂 .

Links of interest:

  1. Debian Med
  2. Linux for Clinics
  3. LinuxMedNews
  4. The Linux Medicine Howto courtesy of The Linux Documentation Project

That’s it for today folks. See ya 🙂 !

Copyright © 2006 – 2008 Firas MR. All rights reserved.

Howto – Play Embedded Real Player Media in Konqueror Using KMplayer

with 3 comments

[Caption: 1st spot! Yay!]

Hi! Getting the plugin that comes with RealPlayer 11 Gold to work with Konqueror 3.5.9 is downright painful.

I figured out a way to make KMplayer work with Konqueror to view RealPlayer files. KMPlayer is nifty in that it can use multiple backend engines – not to mention xine and mplayer. This howto works for Kubuntu 8.04 (KDE 3.5.9).

Let’s get on with the howto:-

  • Download and install Real Player 11 Gold for Linux from here. Follow the instructions in this howto to do so.
  • Next install MPlayer and KMplayer from the repositories. Make sure you have all of the repositories enabled before doing so. Once you’ve done that, In a terminal just do the following:

    sudo apt-get install mplayer kmplayer

  • Now grab MPlayer’s binary codecs from here. The download is actually a single zipped file. Use Ark to extract it.
  • We need to copy all of the codecs to /usr/lib/codecs . Next we need to copy/overwrite some of these codecs with those that came with RealPlayer 11 Gold. RealPlayer’s codecs reside in the /path-to-realplayer-installation/codecs folder. Copy them into the /usr/lib/codecs folder. You can accomplish all of this graphically for this process to be more intuitive. For all of this, Konqueror needs to be run with sudo privileges. So in a terminal do:

    sudo konqueror

    Goto /usr/lib and create two folders under /usr/lib – codecs and win32. Now goto /path-to-realplayer-installation/codecs and copy all of the files to /usr/lib/codecs . Konqueror will prompt you that you’re attempting to overwrite. Have no fear! Proceed 🙂 !

  • Next we need to create symbolic links (shortcuts) to all of the files you just copied to /usr/lib/codecs in /usr/lib/win32 . To do so we do the following in a terminal (although you could try doing it graphically):

    cd /usr/lib/win32

    sudo ln -s /usr/lib/codecs/* .

    Don’t forget that dot! It’s not a typo 🙂 .

  • Now we need to configure the xine engine so that it knows where to look for the codecs. Open up Kaffeine. Goto Settings > Xine Engine Parameters > Decoders and enter either /usr/lib/codecs or /usr/lib/win32 in both fields. Click Apply and then OK. We have configured xine.
  • Now we need to configure Konqueror to use KMplayer to play Real Player files. Goto Settings > Configure Konqueror > File Associations. In the list under Known Types click on audio and select vdn.rn-realaudio. Click on the tab called Embedding. Click on Add and select Embedded player for KDE (kmplayer_part). You might be having other selections already in your Services Preference Order. So remember to place Embedded player for KDE at the very top. Repeat the whole thing with vdn.rn-realaudio, x-pn-realaudio and x-pn-realaudio-plugin all of which also lie under audio and for vdn.rn-realvideo which comes under video. Do the same for vdn.rn-realmedia, vdn.rn-realmedia-secure, vdn.rn-realmedia-vbr, vdn.rn-realplay, vdn.rn.realsystem-rmj, vdn.rn.realsystem-rmx under applications. Konqueror is now configured to use KMPlayer to play embedded Real Player media. Click on Apply and then OK. Restart Konqueror.
  • Test it all out! When an embedded media opens up, an embedded instance of KMplayer should start. You can then specify either xine or mplayer as the engine KMPlayer should use for the media. I’ve found mplayer to be more reliable.

Note that this workaround isn’t perfect and your mileage may vary. You’ll do alright for the most part though 🙂 . Readers are welcome to send in their comments! Cheereo 🙂 .

Readability grades for this post:-

Kincaid: 4.9
ARI: 5.2
Coleman-Liau: 11.0
Flesch Index: 78.7/100
Fog Index: 7.4
Lix: 29.6 = below school year 5
SMOG-Grading: 8.0

Powered by Kubuntu 8.04

Copyright © 2006 – 2008 Firas MR. All rights reserved.

Written by Firas MR

April 29, 2008 at 3:09 pm

Navigating, Exploring and Konquering!

with 2 comments

In case you just noticed, I’ve revamped the entire theme to suit the audacious browser I’ve so come to love – Konqueror. I hope this website is now viewable by most browsers. Happy surfing people!

Copyright © 2006 – 2008 Firas MR. All rights reserved.

Written by Firas MR

April 11, 2008 at 1:31 pm

Posted in Technology, Unix

Tagged with , , , ,

Introducing Kubuntu Hippy Horse Omega Pony!

with 3 comments

Source, Author and License

Oh yea! Boy do I love creativity like this! lol .. This post is wholly and solely dedicated to the geniuses who’ve managed to devise quite possibly the most fantastically, stupendously, hilarious name for any linux distro in recent history! lol !!

Check it out here!

Readability grades for this post:

Kincaid: 6.0
ARI: 5.5
Coleman-Liau: 11.6
Flesch Index: 69.8/100 (plain English)
Fog Index: 10.0
Lix: 32.5 = below school year 5
SMOG-Grading: 9.7

Powered by BlogJet and Ubuntu Linux 7.04

Copyright © 2006 – 2008 Firas MR. All rights reserved.

Written by Firas MR

April 1, 2008 at 9:50 pm

Posted in Technology, Unix

Tagged with , , ,

SMOG, Fog and Similar Things

with 3 comments

[Caption: The STS-92 Space Shuttle astronauts photographed upstate New York at sunset on October 21, 2000. Water bodies (Lake Ontario, Lake Erie, the Finger Lakes, the St. Lawrence and Niagara Rivers) are highlighted by sunlight (sun reflecting off the water surface), making for a dramatic and unusual regional view. The photograph was taken looking toward the southwest from southern Canada, and captures a regional smog layer extending across central New York, western Lake Erie and Ohio, and further west. The layer of atmospheric pollution is capped by an atmospheric inversion, which is marked by the layer of clouds at the top of the photograph. The astronauts were able to document this smog event from a variety of vantage points as they orbited over the northeastern U.S. and southern Canada. Source and License]

It was while reading a page from the Oxford Handbook of Medicine mentioning the Flesch Index and it’s applications to doctor-patient communication that first got me interested into readability indices. I’ve since meandered into some excellent articles (here and here) on the subject and have decided to include scores below each of my future posts . Why? Well, ‘coz it’s fun! I’m generating these scores using the GNU ‘diction’ and ‘style’ utilities (featured in this great article and available for download here. In Ubuntu Linux, just install the diction package through its repositories.). For those of you who’d like to add these stats without having to download anything, this website uses the same backends. The absolutely fun thing with that website is that you can see your scores change dynamically as you type!

For a very brief overview of what these scores mean, here’s an excerpt from the ‘man’ page for ‘style’ (the man page is licensed under the GNU GPL):-

Kincaid formula
The Kincaid Formula was developed for U.S. Navy training manuals; it ranges in difficulty from 5.5 to 16.3. It is probably best applied to technical documents, because it is based on adult training manuals rather than school book text. Dialogs (often found in fictional texts) are usually a series of short sentences, which lowers the score. On the other hand, scientific texts with many long scientific terms are rated higher, although they are not necessarily harder to read for people who are familiar with those terms.

Kincaid = 11.8*syllables/wds+0.39*wds/sentences-15.59

Automated Readability Index
The Automated Readability Index is typically higher than Kincaid and Coleman-Liau, but lower than Flesch.

ARI = 4.71*chars/wds+0.5*wds/sentences-21.43

Coleman-Liau Formula
The Coleman-Liau Formula usually gives a lower grade than Kincaid, ARI and Flesch when applied to technical documents.

Coleman-Liau = 5.89*chars/wds-0.3*sentences/(100*wds)-15.8

Flesch Reading Ease formula
Developed by Rudolph Flesch in 1948, the Flesch Reading Ease formula is based on school texts covering grades 3 to 12. It is widespread, especially in the USA, because it is computed easily and produces good results. The index ranges from 0 (hard) to 100 (easy). Standard English documents average around 60 to 70. Applying it to German documents gives bad results because of the different language structure.

Flesch Index = 206.835-84.6*syll/wds-1.015*wds/sent

Fog Index
The Fog index was developed by Robert Gunning. Its value is a
school grade. The “ideal” Fog Index level is 7 or 8. A level above 12 indicates the writing sample is too hard for most people to read. Texts less than 100 words will not produce meaningful results. Note that a correct implementation would not count words of three or more syllables that are proper names, combinations of easy words, or made three syllables by suffixes such as –ed, –es, or –ing.

Fog Index = 0.4*(wds/sent+100*((wds >= 3 syll)/wds))

Lix formula
The Lix formula developed by Björnsson from Sweden is very simple and employs a mapping table as well:

Lix = wds/sent+100*(wds >= 6 char)/wds

Index 34 <–> 38 <–> 41 <–> 44 <–> 48 <–> 51 <–> 54 <–> 57
School year 5 | 6 | 7 | 8 | 9 | 10 | 11

SMOG Grading
The SMOG Grading for English texts was developed by McLaughlin in 1969. Its result is a school grade.

Grading = square root of (((wds >= 3 syll)/sent)*30) + 3

It was adapted to German by Bamberger and Vanecek in 1984, who
changed the constant +3 to -2.

Having just learned a lot of comp related stuff lately (LAMP server basics being one of them ) and reflecting on this piece of exciting news, I guess there isn’t anything medical on my mind right now ! So with that I end this post.

Do send in your comments!


Readability scores for this post:

Kincaid: 8.6
ARI: 9.8
Coleman-Liau: 11.1
Flesch Index: 68.1/100 (plain English)
Fog Index: 11.7
Lix: 41.9 = school year 7
SMOG-Grading: 10.6


Powered by Blogjet and Ubuntu Linux 7.04

Copyright © 2006 – 2008 Firas MR. All rights reserved.

Extra! Extra! Aegis 2.0 Is Here To Save The Day!

with 2 comments

Source, Author and License

Dual-booters among my brethren will be very happy to hear about a new dawg in the neighborhood. Dual-booters, in this case refers to people booting Windows as well as Linux. Typically these users will access potentially virus infested files from Windows in their day to day lives and in this process might hurt other users using Windows as their sole operating system without even knowing it (Why? Because, Linux for the most part isn’t a major target by viruses and is a lot more seure). This could happen in a variety of ways, from sending an infected attachment by email to lending a friend a corrupted CD. To my knowledge, until now most virus scanners running on Linux aren’t real-time/resident scanners, meaning that they only scan files when you ask them to – on demand. Newer versions of AVG for Linux, etc. provide a resident-scanning function with a prerequisite that you install the Dazuko module. As I recently learned what modularity in the computer world actually is, here’s a starter for the uninitiated. Operating systems (OS) can be divided into two basic groups – Monolithic and Microlithic. These terms denote how drivers for your hardware and similar stuff much beyond my comprehension as a medic come built with your OS. What is a driver? Before we come to that, know this first. At the very heart of any OS is what’s called a kernel. The kernel is the first thing that boots up when you start your PC. When you’re typing in MS Word and reading the letters on your screen as you type, a variety of things happen culminating in the kernel speaking to your hardware exactly what you want your hardware to do. It does this by means of ‘drivers’ that allow it to speak to your hardware. Drivers can be built into the kernel itself or can come as what are called ‘modules’ that can be activated or deactivated as needed independent of the kernel’s function. An OS with the former configuration is called a Monolithic kernel while the latter is typical of a Microlithic kernel. Because a Monolithic kernel contains all the drivers patched into the kernel itself, it’s a little slower to boot than a Microlithic kernel. The fun thing about modules is that you can activate or deactivate them even as you’ve already booted into your OS and are working on your email, watching movies, etc. No rebooting required in this process afaik. Anywho, so coming back to our main discussion, Dazuko is a piece of software that you can either patch into your kernel itself or load it as a module. AVG for Linux requires Dazuko installed to be able to act as a realtime scanner.

I’m a firm believer in usability than anything else. Especially for average computer-idiots. As a matter of fact my tryst with Linux started due to the continuous slow-downs and virus threats in Windows. I still do love the general user interface and ease of use of Windows. I also like things cheap and don’t like to be cornered into a position where I’d be forced to use cracks, keygens and illegit stuff which for all I know might contain malicious code. Not being a software developer or anything like that (although you’d be interested to know there are medics who are hard core devs too, like Dr. Con Kolivas who is a practicing Anesthesiologist in Australia and maintains their society’s website), the ‘free as in speech doesn’t really get my attention as much as the ‘free as in beer’ aspect of Linux. Although, if I were to be a medical entrepreneur who wishes to start some sort of business or a hospital system, etc. I’d view the ‘free as in speech’ aspect with due respect too because in that situation I would be able to build a custom OS for my business needs, hiring an IT team.

For those of us who’d rather not install Dazuko and immerse ourselves in uber-geeky stuff, there’s a really cool development in the Linux Antivirus world. Aegis 2.0, a project in the alpha stages (meaning it’s not stable yet), is a real-time scanner not requiring Dazuko. Not as far as I can tell from its website.

Here’s an excerpt from the website:-

Aegis 2.0 is a ground-up rewrite of the Aegis Virus Scanner. It was developed as a modular and flexible system that can support multiple backends for monitoring and scanning. Even the user interface is decoupled so that it would not be hard to write an interface for another desktop such as KDE.

The old Aegis was a simple “on-demand” scanner – you ran the application, chose a directory, and the program scanned it for you. Aegis 2.0 is a background scanner – it resides in your desktop’s notification area, and watches for new or modified files in your home directory. When it finds an infected file, it shows a dialog, allowing you to delete or quarantine the file.

So go ahead fellas, check it out here!

Feel free to leave behind your comments .


Powered by BlogJet and Ubuntu Linux 7.04

Copyright © 2006 – 2008 Firas MR. All rights reserved.

Written by Firas MR

March 24, 2008 at 12:03 am