Ok, further testing seems to confirm that it is the two functions printCustomAlbumThumbImage() and printCustomSizedImage() that cause the problem, depending on the number of parameters. Here are my test scenarios:
1) If I clear the cache, then call printCustomAlbumThumbImage(getAlbumTitle(),null,100,100) and printCustomSizedImage(getAlbumTitle(),null,100,100) the images are distorted, both for the album and image thumbs.
The cache contains images named as follows:
IMG_NNNN.JPG_w100_h100.jpg (both for the album and image thumbs)
2) If I clear the cache, then call printCustomAlbumThumbImage(getAlbumTitle(),null,100,100,100,100) and
printCustomSizedImage(getAlbumTitle(),null,100,100,100,100) the images are cropped correctly, for the image thumbs but incorrectly for the album thumb.
The cache contains images named as follows:
IMG_NNNN.JPG_w100_h100_cw100_ch100.jpg - cropped correctly for the image thumbs, and
IMG_NNNN.JPG_w100_h100.jpg - still cropped badly for the album thumbs.
The problem is totally reproducible. I did the above tests on a clean install, clean cache each time.
So, for the image thumbs, the solution to the problem is to always call the printCustomSizedImage() function specifying all four parameters: width, height, crop width and crop height. This, however, does not fix the problem for the album thumbs generated by printCustomAlbumThumbImage().