Rooturaj's Blog

The words of a Techie who loved Nature.

Archive for January, 2010

PHP Image Resize script – Resize Images on the fly

Posted by rooturaj On January - 30 - 2010

What does this Script do?

It changes the dimensions and hence the file size of  image files on the fly. All you need to do is specify a source file, set the new dimensions and this PHP class will generate the new re-sized image for you.

Who should use this?

Any one who needs to re-size their images automatically.

For example: If you need to generate thumbnails for the images uploaded to your image sharing site then this is the solution for you. Sometimes we need to display smaller images to save band width and improve page load time.

What does this need?

PHP 5 + GD Library

(and of course the image files to manipulate and apache server)
To check if you have got GD library on your PHP bundle Create a php file with the following code and run it.

<?php
phpinfo();
?>

Let’s get working then.

Here is the Class File. It contains two functions resize() and resize_const(). The first one only takes in a width value with the source file and generates a new image with height in constrained proportions. While resize_const() takes in width, height and source file to generate an image of exact dimensions.


<?php
class ImgResizer {
private $originalFile = '';
public function __construct($originalFile = '') {
$this -> originalFile = $originalFile;
}
public function resize($newWidth, $targetFile) {
if (empty($newWidth) || empty($targetFile)) {
return false;
}
$src = imagecreatefromjpeg($this -> originalFile);
list($width, $height) = getimagesize($this -> originalFile);
$newHeight = ($height / $width) * $newWidth;
$tmp = imagecreatetruecolor($newWidth, $newHeight);
imagecopyresampled($tmp, $src, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height);
if (file_exists($targetFile)) {
unlink($targetFile);
}
imagejpeg($tmp, $targetFile, 85); // 85 is my choice, make it between 0 – 100 for
//output image quality with 100 being the most luxurious
}

//the function below will get you an image with the width and height values set by you.
// In case you need exact size images.
public function resize_const($newWidth,$newHeight, $targetFile) {
if (empty($newWidth)|| empty($newHeight) || empty($targetFile)) {
return false;
}
$src = imagecreatefromjpeg($this -> originalFile);
list($width, $height) = getimagesize($this -> originalFile);
$tmp = imagecreatetruecolor($newWidth, $newHeight);
imagecopyresampled($tmp, $src, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height);
if (file_exists($targetFile)) {
unlink($targetFile);
}
imagejpeg($tmp, $targetFile, 85); // 85 is my choice, make it between 0 – 100 for output image quality with 100 being the most luxurious
}
}
?>

Using the Class and the Functions.

Use the code below in as where ever you want it to work. (I am sorry but that does not include pasting the code on your photo frame)


<?php
$work = new ImgResizer('path/to/original/image.jpg');
$work -> resize(75, 'path/to/resized/image.jpg');
$work = new ImgResizer('path/to/original/image.jpg');
$work -> resize_const(200,150, 'path/to/resized/image.jpg');
?>

This is not my original code. I am building upon this base.

Kaspersky Detects Trojans in Google Adsense

Posted by rooturaj On January - 25 - 2010

I don’t know if it affects you or if my Anti-Virus is just acting up but every time I force refresh a page with Google Adsense with it Kaspersky (ver: 8.0.0.454) Internet Security detects a Trojan on the google javascript file. This even comes up on leading sites like lonelyplanet.com.

Here are the details.
To force refresh I mean using CTRL + F5. Then my antivirus gives this message.

Kaspersky detects Trojan on Site with Adsense

Kaspersky detects Trojan on Site with Adsense

On further checking of this report Kaspersky gives me the following actions and errors.
This is the actual error report on Kaspersky. 1/25/2010 8:01:18 PM- http://pagead2.googlesyndication.com/pagead/show_ads.js Firefox Processing error: Trojan.JS.Redirector.ar

Report points to Adsense file

Report points to Adsense file

I get the same issue on IE6 with Kaspersky. On Internet Explorer I with Kaspersky installed I get an Additional Error. See Below.

Issue duplicates on separate machine with IE6 and Kaspersky

Issue duplicates on separate machine with IE6 and Kaspersky

I have no idea whats going on. After a basic search on Google I found this related post. But this is an old case and the ads are not being hijacked. From the report it seems it is the original Google Adsense Javascript file that is being detected as malicious.

If some of you have kaspersky could you please test this issue at your end and let me know. I will mean while report this to Google.

Checkout My Room on YooWalk

Posted by rooturaj On January - 25 - 2010

Hey Guys. I just found an amazing place to kill time on web. If you thought Facebook was the ultimate time killer social platform then here is something you must check out. I recommend yoowalk.com for the ultimate social networking freaks.

For some time I have been looking for a change from Facebook. This one comes as a fresh new idea for internet marketing as well as social networking. Yeah I know you are asking me how it is better than Facebook. For all those who have a Facebook page compare yours with my yoowalk room. See below. (if you can’t see the flash loading then click here to see my room)

Walk around. Yeah I mean it. Just walk around.
If you want you can take a nap on my sofa.
Use the speaker to listen to my songs. There are two at the moment. (might take some time to load)
My fishes are really cute. All you non non-vegetarians don’t even think about it.
The bath tub is for babies. No messing in there.

Need I say that if you are there you must add me as your friend?

Google Says Bing is the Best Search Engine – OMG Bing Is King

Posted by rooturaj On January - 23 - 2010

Just out of curiosity I searched the term “Search Engine” on Google. I was actually testing if Google returned google.com for the term “search engine”. This is what I got. (see snapshot below)

Wow, according to Google, Bing is the No One Search Engine on the planet. Interesting, eh?

google-says-bing-is-king

Bing Is King - Google

This was the result on google India. There were different results on Google.com.

So to what extent are these listings valid? Shall we take that as the real results? I do a wee bit of SEO so I ask from the SEO angle. Is it possible that Bing could have mustered more backlinks than yahoo and Google for the keyword “search engine”. I wonder.

What does Google want here? May be they feel shy suggesting their own name when someone asks them ‘which is the best search engine around’.

Well there is always the obvious fact that we must consider here. Since the search is being made on Google the user is aware of Google. So the result google.com looses relevance. But that does not answer the question? Is this factor included in the algorithm? If no, then these are filtered results with the previously mentioned factors included.

But if you want to filter yourself then go off completely. What does it mean when google.co.in and google.com feature on the next page of results after www.123khoj.com and www.mamma.com . I say these results are strange. What do you say?

Bhoot chad gaya re Music Video| Rakhi Sawant | Controversy

Posted by rooturaj On January - 21 - 2010

Now this is about the fiasco about the latest Rakhi Sawant album. For those who don’t already know India’s no.1 (who decides these titles – not me) item girl just launched a new album with Canadian hip hop artist IshQ Bector. So what’s the big deal?

Rakhi-SawantActually I like the marketing strategy that these people follow. This is a very interesting and low budget promotion trick that almost always delivers. All you need to do is to create a controversy. If you are even a little known celebrity the media will catapult you into limelight. TV channels will repeat your controversial music video N number (where N tends to infinity). So the normal viewer and reader will be so bugged that he will finally get the music video to see what the hell is this all about.

I did the same. Now don’t give me that look. Blame the media. Watch the video here.

Now this could be a repeat compilation of the promo video. What ever it is it tastes yuck. Rakhi is such a gross Hip Hop performer. Good try nevertheless. But she needs to try harder.

I feel the sensor board did the right thing to hold it but they gave the wrong reasons. They should have instead censored the song for being crapy. Rakhi now has a very valid reason for suing the board for holding the song just because it uses the word “kaminey”. They did allow the super hit movie “Kaminey”.

Here are some more music videos in this series – Jhagde ( Rakhi Sawant and Ishq bector)
http://www.youtube.com/watch?v=GjuzXW91KkE

Hacking into your life through your emails

Posted by rooturaj On January - 20 - 2010

I am going to share with you a funny but serious event that unfolded in my Inbox yesterday. There is a silly job listing site in the name of jobszone.info. They blast bulk mails to thousands of people about latest job openings. Yesterday I received a mail from them that reads.

mail from idiot

Now what does a user like me do in this case. Carelessness like this leads to the hacking of email accounts and corporate websites.

Here is how a hacker would proceed once he is fed with information like this. I am not a hacker but I have read about them and I am somewhat familiar with their train of thought. Thanks to recent events like Iranian attack on Twitter.and previous Twitter Admin hack news.

So first of all we try out popular mail portals like Gmail, Yahoo, Hotmail, AOL etc. If our trial yields no result then we try to access the webmail accounts using urls like domain.com/webmail or mail.domain.com. How to find out the site? Use google for the most relevant term from the mail. It is not always that easy though.

In my case I struck gold with Gmail. Though I tried the domain.com/webmail approach first as the mails seemed to originate from the said website.

Normally what first timers would do is reset the password. But that is the stupid thing to do. Don’t let the original user suspect that the account has been compromised.

Next search for password or username using mail accounts search feature. Gmail in this case is just wow. I got around 40 results. This idiot left an excel file with a list of user ids and passwords for some 25 accounts. Wow. I can further use the same to get into more classified information. May be I could find some credit card details too but my ethics stop me going beyond this. LOL

Additionally one could use Gmail labels or folders in other email clients to reach out to specific information on your email accounts.

I hope this malicious email account access process would give you enough ideas about how to protect your accounts from being hacked. Many large organizations like twitter have been hacked using this very method.

This has been a long post already. Watch out for my next post that is a list of steps to keep your accounts safe from hacking.

Facebooks Retweet Equivalent | How to Use Facebook Via

Posted by rooturaj On January - 16 - 2010

We are all familiar with twitter’s RT (retweet) features. Now Facebook has started a similar feature on the lines of Retweet. This is a short post on how this feature works and the advantages it will bring to Facebookers.

Retweet feature that first started on twitter as a practice of preceding any post that you want to re-post to your followers with a RT and @originalusername. Now we have dedicated retweet buttons as it became massively popular. @mentions on Facebook also caught up soon. Now its time for RTs. The main idea behind RTs on twitter of Via on Facebook it so credit the original poster for his contributions. Lets see how they work.

This feature is now available to the public and only works on links for the time being. That is you cannot “via” your friends status updates or shared videos. All You need to do is use the good old share option on a link posted by your friend. Then notice the change marked red.

Facebook-Via-like-retweet

You can choose to remove the via feature if you like to. (note the remove link) I would strongly suggest you keep it. This would let people know who the original poster is and you won’t be involved with the nasty incidents that follow when you share something that does not match everyone’s taste.

On twitter we have some thing like this.

twitter-retweetEnjoy the new feature. I hope this is implemented on status updates as well.

Contributors needed for a Travel Blog

Posted by rooturaj On January - 14 - 2010

Dear Friends,
I had started a blog targeting “places to visit in India” some time last year. I has just around 10 posts till now but it does pretty well on search engines without any promotion or SEO. I am looking to leverage its reach this year and scope this year by focusing on more quality content and better coverage. I am also in talks with a couple of service providers and travel agent to etch out a profitable business model. Right now I am counting on content and as we build a credibility in market we will go work hard on the return of investment..

In this regard I call upon all those who are passionate about writing and traveling to contribute to the blog. Your contribution will be duly acknowledged. Here are a few ways in which you can utilize this opportunity.

1. Budding writers can reach out to the world and use this opportunity to showcase their writing. Feel free to use your contributions to negotiate a higher pay package or a better job.
2. Established writers can expect a royalty payment or pay per article reimbursement system.
3. SEOs and Link builders can use their content writers to take back relevant links in exchange for original and useful content.
4. Friends – Just contribute.

In case their is any thing better on your mind do let me know. Even if its some thing worse on your mind let me know too. Use the connect buttons to the right.

Contributors wanted for Indifest.in

Contributors wanted for Indifest.in

Mom I am not Ready yet | Womb Raiders forcing prenatal competition

Posted by rooturaj On January - 11 - 2010

3-idiotsYesterday I saw the movie 3 Idiots. This is a true tale of India’s educational system. It is competition form day one after your birth. If you are in a metro city like New Delhi and Mumbai you know how difficult it is to get into a decent school. What right do we have to kill the colorful world of  a four year old kid. They have to sit interviews and are bred to see their friends as competitors. (img Src : Santabanta.com)

While scanning through some of the products online at the CES 2010 I came across some weird ones. This particular device called “BabyPlus Prenatal Education system” has been intriguing me for the last few hours. Was it not enough that you are taking the fun out of kids at the age of 3.  Isn’t Home work and ranking system a curse big enough?  You want to ruin their lives even before they see the light of the world?

Womb Raiders

Womb Raiders (src:usposttoday.com)

This device produces a range of sounds that mimic mother’s heart beat. Their bull shit research shows this will make your baby more “interactive, responsive, relaxed and alert”.  I might put it in another simpler way if you would like to hear. Your child will be “stressed, restless, pissed off and sleep less”. The mother has to wear the device two times, one hour each time. If you can hear the poor chap inside, it is saying – “Mom – I am not ready yet.”

If the mother’s heartbeat was that good for the fetus then the wombs would be the chest and not in the pelvis. Nature has had a longer time experimenting with us than these people. I am not against technology but something like this that is totally profit motivated and has the potential of deeply influencing out social setup should be controlled; better banned.

To end my rambling I say the power still lies with the consumer. Tell them what you want for your kid. They have a life of their own. Don’t force it upon them. Let them choose.

Why Kal Kya Hoga Facebook app had to die

Posted by rooturaj On January - 8 - 2010

There used to be an app on Facebook till yesterday called Kal Kya Hoga. This bull shit application transgressed the line between lite humor and public slandering of unsuspecting Facebook Users. These involved serious privacy violation and defamation that not only affected involved facebookers but their friends and families as well.

I site this instance because it happened to me and I swore I would stamp out this nonsense for ever. I never subscribed for this app – Kal Kya Hoga, but one of my friends did. This application takes in a friends name and throws out some random nonsense that is supposed to happen to the friend in future. I understand this is supposed to be funny but there is a limit to every thing and on this occasion it did cross the limit.

Here is the blotted snapshot of the app. It was a blatant attack on my character and I was in no mood to take it lightly. Not just that, it is an attack on my family as well. Its a different matter that I am not married.  It could have soured relations between me and the friend who published the same. Why should I loose a great friend for a sick and sightless software application created by some dung-brain programmer?

Kal Kya Hoga Blasphemy

Kal Kya Hoga Blasphemy

It could be happening to many more people. I shudder to think what degree of insults these people would be coming up with. This had to stop.

I reported the matter to the company that helped create this app – Phrases, by smsocial.com. Their first response was casual and it seemed they wanted to brush aside this issue. Here is their reply.

First reply form PhrasesTotally dissatisfied I shot back the following.

Rooturaj-Phrases-email2At the same time I reported the matter to Facebook too. Then it worked. The snake was nailed. Kal Kay Hoga app got what it rightly deserved – the Ban.

Phrases-Rooturaj-mail3

I am grateful to the creators of Phrase for the maturity they have shown in addressing social security issues. This will not only cement your reputation as professional developers for social media platforms but mark you as a team of caring individuals too.

A word to fellow Facebookers.
Do take such instances seriously and report them as required. Read once what you are publishing on the social media. If it is not appropriate for your parents, younger siblings or weaker section of society do not publish it. It hurts others and in this process you could loose a valuable friend. I am not sure if you can see it but it actually is a huge loss.

*Disclaimer : There are some people and companies mentioned above. If for any reason you feel this is incursion into your privacy just let me know.

VIDEO

TAG CLOUD

Sponsors