A new cryptographic method for encrypting still images is proposed. This method is designed on the basis of the base-switching lossless image compression algorithm. The method therefore simultaneously possesses both image encryption and lossless compression abilities. A given image is first partitioned into nonoverlapping fixed-size subimages, and each subimage will then have its own base value. These subimages are then encoded and encrypted one by one according to the base values. By choosing the function to encrypt the base value, there are (128!)t [or (128!)3t] possible ways to encrypt a gray-scaled (color) image if t layers are used in the encryption system. The theoretical analysis needed to support the proposed encryption method is provided, and the experimental results are also presented.