Only use preset resolutions for image calculations

Script is changed to pick a resolution that best matches the resolutions found in the resolution array. Thus fewer images need to be generated. DPI is factored in. If your max resolution is 480 and your DPI is 2 and you have a value in the array of 1024 it will pick 1024 because it is the closest value that is still >= "test".

Additionally changed the cache folder to use /$resolution/hash as the cache file.