Implemented initial phase of the image-packing algorithm.