I would love to get some advice on how to handle images in a good way.
I have several websites built with jekyll. Each website utilizes various images. Often times, as I work with a website, I may want to quickly change an image from one resolution to another resolution to see how different it would look, etc. In order to not have to open each image and resave it, I just generate multiple versions of each image and then encode the resolution, quality, etc in the filename. So that I can easily change src=picture-300x300.png to src=picture-900x900.png…
This is how I currently do this:
I have a _images
folder with my “source” images in.
Here, I store the actual photographs or other graphical assets that I want to put on the site. This could include the actual RAW images, or PSD files from Photoshop, etc… I then also store a web-format version of the image which would have the same file name but with .jpg, .webp, .png, etc. as extension.
I then have a script to “build” the images. It basically goes through _images/*.{jpg,png,webp,gif,heic}
and then uses ImageMagick to generate a lot of versions of each image, including different resolutions (32x32, 64x64, 128x128 for various icons; 100x100, 150x150, 200x200, 300x300, 600x600, 900x900, 1200x1200, 1800x1800, 2400x2400, …) and also different compression quality targets, like 40, 50, 60, 70, 80, 85, 90, 95, which are mostly relevant for jpeg.
Each of the images produced are stored in assets/images/$filename-$resolution-$quality.$extension
This also means that each source images in _images will produce dusins and dusins of output files in assets/images. And only few will be used…
This is of course hugely inefficient. The assets folder explodes in size and number of files and most will never be accessed…
Also, I will have to run my image build script manually every time I add new images…
I am sure there are others who have similar needs and who have solved this in a much better way…