Thursday, January 15, 2009

Detect identical & black frame in video with ffmpeg?

Thumbnail creation is a very needed feature for any social networking site. Obviously, ffmpeg is the ideal solution for generating thumbnail.

Problem-1: Detecting identical thumbnails

Fortunately, we have a good solution--libpuzzle. It would be ideal to have a filter in ffmpeg for that.

Problem-2: Detecting black/dark frames

I'm still keenly looking for a solution tied up with ffmpeg. When Google turned no help, Heleena (my wife) solved it by calculating average luminance value of the frame and ignoring the frames based on certain preset threshold value--which worked better at that time.

Friday, January 02, 2009

Converting PSD with PHP/ImageMagick

After seeing feature rich options in Imagick PECL extension at Mikko Koppanen's (the author) website and also impressed with ImageMagick's features, I have decided to use it for the PSD to XHTML conversion website that I'm architecting and managing.

Since, the team wants programming help for converting PSD images, I have tried it (documentation is sparse on PSD handling)

Converting PSD to PNG/JPEG/etc

Note that, flattenImages() is needed for layered/multi-page PSD file.

$im = new Imagick('test.psd');

Extracting PSD layers

One by one

$im = new Imagick('test.psd');
for ($i = 0, $num_layers = $im->getNumberImages(); $i < $num_layers; ++$i) {
$im->writeImage('layer' . $i . '.png');

Note that, there is a better version below

In a single call with writeImages()

$im = new Imagick('test.psd');
$im->writeImages('layer%d.png', true);

Note: Second parameter of writeImages() is for adjoin


While doing so and comparing with the results of XnView, I have noted a same problem/issue as mentioned here in the forum--that is, most of the extracted layers/images are distorted. By the way, I have tried in WAMP and yet to try it in LAMP