Introduction: Meibomian gland dysfunction is a common cause of dry eye syndrome which can also lead to eyelid inflammation. Today, diagnostics of meibomian glands is not fully automatic yet and is based on a qualitative assessment made by an ophthalmologist. Therefore, this article proposes a new automatic analysis method which provides a quantitative assessment of meibomian gland dysfunction. Method: The new algorithm involves a sequence of operations: image acquisition (acquisition of data from OCULUS Keratograph (R) 5M); image pre-processing (image conversion to gray levels, median filtering, removal of uneven lighting, normalization); main image processing (binarization, morphological opening, labeling, Gaussian filtering, skeletonization, distance transform, watersheds). The algorithm was implemented in Matlab with Image Processing Toolbox (Matlab: Version 7.11.0.584, R2010b) on a PC running Windows 7 Professional, 64-bit with the Intel Core i7-4960X CPU @ 3.60 GHz. Results and conclusions: The algorithm described in this article has the following features: it is fully automatic, provides fully reproducible results - sensitivity of 993% and specificity of 97.5% in the diagnosis of meibomian glands, and is insensitive to parameter changes. The time of image analysis for a single subject does not exceed 0.5 s. Currently, the presented algorithm is tested in the Railway Hospital in Katowice, Poland. (C) 2016 Elsevier Ltd. All rights reserved.