Fast and effective image compression for multi-dimensional images has become increasingly important for efficient storage and transfer of massive amounts of high-resolution images and videos. In this paper, we present an efficient in-situ method for multi-dimensional image and video compression called Compression via Adaptive Recursive Partitioning (CARP). CARP uses an optimal permutation of the image pixels inferred from a Bayesian probabilistic model on recursive partitions of the image to reduce its effective dimensionality, achieving a parsimonious representation that preserves information. Furthermore, it adopts a multi-layer Bayesian hierarchical model to achieve in-situ compression along with self-tuning and regularization, with just one single parameter to be specified by the user to achieve the desired compression rate. The properties of our proposed method include high reconstruction quality at a wide range of compression rates while preserving key local details, applicability to a variety of different image/video types and of different dimensions, computational scalability, progressive transmission and ease of tuning. Extensive numerical experiments using a variety of datasets including 2D still images, real-life YouTube videos, and surveillance videos show that CARP compares favorably to—and often uniformly outperforms—a wide range of popular image/video compression approaches, including JPEG, JPEG2000, AVI, BPG, MPEG4, HEVC, AV1, and three neural network-based methods.