A modified run-length algorithm with Peano-Hilbert scanning is described. In this approach, quantization is integrated within the run-length calculation, and is controlled by a radius parameter. A zero value of radius will produce lossless coding, while greater than zero will produce lossy coding. The Peano-Hilbert curve scans a 2D array with local plane filling priority. Compared with the standard raster and zigzag scanning, the Peano-Hilbert scanning enlarges pixel covariance as distance between pixels increases. It, therefore, enhances run-length compression ratio as degree of lossy increases. Output of the run-length encoder is further entropy coded using a decomposed Huffman encoder. The proposed method can be applied directly to a raw image or combined with DPCM, wavelet or subband transforms. If the transform is also implemented with integer arithmetic, such as in the lossless JPEG or reversible wavelet transform, a unified lossy and lossless compression is achieved. The method is simpler than the JPEG standard, and yet achieves roughly equivalent performance when combined with DPCM. Decoding is very fast as no de-quantization procedure is needed. Experiments with various types of images have shown its speed advantage and compression efficiency.