Categories
Python

Image Resizing With Python

At my workplace, I’m bound to work with PHP but not at my home 😀 For PHP, I’ve seen cool image libraries like the GD library, ImageMagick and in-numerous classes to manipulate images. But what does Python have to offer when it comes to image manipulation ?

Python doesn’t have any native modules to work with images ( a big exception to the “batteries included” motto? ). PIL or the Python Imaging Library is the most popular one I found. It’s just awesome. It will remind you the difference between Python and other programming languages. I was seeking a solution to convert my php image resizing script into Python. I want to distribute the solution among my non techie friends. PHP is overkill for them though I could build a php-gtk app for easy use. But still, the runtime would have been heavy. And I always like Python for distributable apps.

When I looked into the PIL, I was surprised to see how easy it is to resize images. No need to dive deep into the basics of image manipulation. Just open a image and use the resize() method.

Have a look:

Isn’t it easy?

To run it, you need the PIL. For Ubuntu, get it by typing:

For Windows and other platforms look here:
http://www.pythonware.com/products/pil/index.htm

Enjoy! 😀

Categories
Personal

Using Moneybookers from Bangladesh

Moneybookers is a service similar to paypal except that they have less coverage and they let Bangladeshis sign up for their service and use it efficiently. www.moneybookers.com is the URL. Those who need to receive money from abroad ( mainly for outsourcing ) can use this service for efficient money transfer. Their service is cheap and affordable.

Case Study: My Story

I use ScriptLance for outsourcing and earn a decent amount of money working at my leisure side by side of my studies at KU. I also work as a part time remote web application engineer for BRE LLC. I used to use the verified paypal account of my partner at JOTIL21. But Moneybookers have made things even simpler. Both Scriplance and BRE LLC Authority sends me payment via moneybookers and I receive the money directly into my Dutch Bangla Bank Limited account with just a few clicks. I’ve added and verified my DBBL account to my Moneybookers account and it’s all done!

Adding and verifying your Bangladeshi bank account is quite easy. Let me walk you through:

1) Register at Moneybookers (www.moneybookers.com)

2) Add funds to your Moneybookers account from other online sources. ( Withdraw fund from your employer to Moneybookers ). I withdrew funds from Scriptlance to Moneybookers.

4) Add a bank account with their SWIFT code. SWIFT is a messaging system used by most Banks for international financial messaging ( mostly transaction related ). For DBBL, it is : “DBBLBDDH “.

3) Try to withdraw money. You’ll be asked to verify your address or Bank account. You will be able to withdraw less than 15 USD before you verify. So, I withdrew $14.99 to my DBBL account.

4) It took around 10 days for the money to arrive home. I went to DBBL Khulna Branch and asked for the verification code that came along the transaction.

5) I collected it and put into my moneybookers account. To do that, I tried to Withdraw again. They again asked me to verify, I picked up the option that said something like “I already have the code”. I entered the code and my account become verified.

Now, I can withdraw around $2000+ in a 90 days period. This limit can be pushed further by verifying your home address and debit/credit card. But I’m happy with what I’ve got. They charge around $2.16 for every transaction no matter the amount is small or large. I use the DBBL ATM card to withdraw money from anywhere in BD. 🙂

Categories
PHP

Using Gedit as a PHP IDE

I’ve been using Ubuntu 9.04 as my primary OS for a while now. I love the power and flexibility of this free and open source OS. Besides PHP, I code Python mainly. I use the Netbeans IDE for PHP and the built in Gedit editor for editing all other sorts of text files and scripts. I like the simplicity and lightweight nature of this editor. Netbeans IDE is very good for web application development. Specially, I have always enjoyed the project management features for easy management of my different projects. The main reason I have been using Netbeans is the Alt+Shift+F command. The formatting option that reformats my entire page with appropriate indentation and makes it readable. Yes, it is cool! But I hate the sluggishness of Netbeans. I know, this is the fault of the slow JVM. Also, when Netbeans lose the focus and regains later, I need to right click or interact with the GUI before I can start typing. This was pissing me off. So, I started using Gedit for quick fixes and hacks. I like the font of the editor, not to mention the cool color schemes. I was wondering if there were any plugins for Gedit to format php codes like Netbeans.

No, there is no dedicated plugin for that. But Gedit has the ability to use external tools to interact with the documents. I installed the php_beautifier pear package and used it with Gedit to partially achieve what I was looking for.

1) I downloaded the PHP_Beautifier package from PHP Pear (http://pear.php.net)
2) Installed it by typing:

The pear package installed a command line utility “php_beautifier” which lets us beautify php codes.

3) Open Gedit. Go to: Edit > Preferences. Visit the “Plugins” tab and activate the External Tools command.

4) The plugin will enable you to let external commands help you process the document. Let’s build our php beautifier for Gedit.

5) Go to: Tools > External Tools. Click “New”. Fill up the form like below:
Description: PHP Beautifier
Shortcut Key:
Commands:

Input: Current Document
Output: Replace Current Document
Applicability: All documents.

You can click on the “New Tool” label to rename the tool. Let’s rename it to “PHP Beautify” and close the dialog box.

Now, we are ready to beautify our php codes from Gedit. Just type in some php codes. Go to: Tools > PHP Beautify and see the output. Please Save the document. You can’t edit the document unless you save after the processing.

PS: Please remember that, it beautifies php only. It will not be able to beautify inline html and php together. I am looking for some command line tool that can help me achieve that. And then, I will say goodbye to Netbeans and stick to Gedit 🙂