Made sampleSize a variable for image compression