Applying the lighting method to a perfect mid-tone gray is probably the best solution, provided the lighting image only adds pure white and pure black tints to images.
It can then be applied to any image using methods shown in...
Lighting Mask Technique
http://www.imagemagick.org/Usage/thumbn ... hting_mask
As a lighting effect that is actually VERY likely what photoshop is doing, though with size adjustments.
For the more general case (not needed here but for others reading this)
If the lighting mask adds other colors, That is complete replacement of a pixel with some color other than white or black (or transparency), such as a when somthing is obsuring the image (like in a page curl), then a simple and single lighting mask image will NOT work. Basically you can not extract the lighting mask from just ONE single image, and you may not even be able to store the effect in one image as some form of second 'mask' image will also be needed.
If that is the case you need at least TWO very different background images (say pure white and pure black) so that you can extract the complete color and alpha shading effects. This is explained in
Masking and Background Removal -- Two Background Technique
http://www.imagemagick.org/Usage/maskin ... background
If you do not have the luxury of two backgrounds, then other less than perfect methods will need to be used.