In this paper, we propose a coding algorithm for raw images with high dynamic ranges. Our encoder has two layers. In the first layer, 24 bit low dynamic range image is encoded by a conventional codec, and then the ratio image that represents the difference between the decoded 24 bit image and the raw image is encoded in the second layer. Experiments shows compression efficiency is significantly improved by taking an inverse tone mapping into account.