verifying that target is img before trying to calculate pixel color