I want to autotake a photo from the camera on my MacBook Air and put the photo in a folder.
Is it possible?
Indeed it is possible. There are several command line utilities that you can use. I have setup a script in my Air to take a picture whenever it wakes up by using imagesnap.
You can run imagesnap from an applescript or you can use cron to schedule it to take a picture at a time interval.
Another option would be EyeSight, which is an app that automates the whole process of taking a picture and saving it to a folder (or upload it via FTP) every N seconds.
Edit: I misread the title of the question and thought you only asked for automated pictures in time intervals. To answer your question, that is, to take a picture with your Air's cam everytime you open the lid you can use a combination of imagesnap and sleepwatcher.
You can hack around some solution using sleepwatcher and imagesnap. Here's the description how to do that: how to
Or you can use an app that does exactly that - Selfie App - but it's paid app on the Mac App Store.
Full disclosure: I'm the author of Selfie App