If original image had no alpha channel, modified image won't either

(exception in the cases where the modification requires an alpha channel)

I need to know if an image (after scale/crop) has an alpha channel to know if I can safely save it as JPEG (my images are mostly photos).

This modification keep opaque images opaque.