A custom-built laser based technique for mass spectrometry enables the imaging of samples with non-flat surfaces. The tool uses a distance sensor to record a height profile of the sample before the actual chemical imaging. Since most samples encountered in chemical ecology do not have flat surfaces, the novel tool could be useful in measuring the distribution of chemical compounds in these samples in order to answer ecological questions more accurately.