We consider the problem of compression of RGB and multispectral images by context-based methods. The algorithm' logic allows for its examination by using the example of full-color images as a particular case of multispectral images. The image-forming channels are divided into two groups: main and additional (detecting) channels. A distinguishing feature of the main channels is a significant correlation between neighbors. A number of variants of prediction from the adjacent channel for the main and additional channels for lossless image compression were considered. In the experiment on a series of images of different contents, the proposed algorithm showed a superior compression ratio in comparison with the popular WinRar, 7z, PNG archivers for all prediction variants. The leader among popular compression methods, JPEG-LS, was surpassed in the record configuration 2b on the image from the Landsat series by 40%. We expect to continue research on a wider sample of images and to use this algorithm to compress multispectral images with a greater number of channels.