<p>Have a n-tire web application and search often times out after 30 secs.  How to detect the root cause of the problem?</p>

A simple solution:
Encode the image as a
jpeg
and look for a substantial change in
filesize
.
I've implemented something similar with video thumbnails, and had a lot of success and scalability.