Equal-height Thumbnails (Like Google image search)
Posted: Thu Feb 04, 2016 11:45 pm
Problem:
One problem with the thumbnail browser is all the wasted space in the screen: a folder full of landscape pictures has big gaps between each row, while a folder full of portrait pictures has big gaps between each column.
Solution:
A much better way of displaying thumbnails is to make all the thumbnails in each row equal height! (like Google image search does).
Not only is it more attractive, but it gets rid of all the wasted screen space, allowing more thumbnails on screen, and much larger thumbnails.
Here is an image I made to demonstrate the difference:
http://i.imgsafe.org/fb5c94b.png
Edit: another example where the aspect ratios are more mixed:
http://i.imgsafe.org/af48e66.png
I would really love XnView to display thumbnails this way. I would call this option "Dynamic Thumbnails" and turn it on by default.
User Preferences
This option has two user preferences:
A. "Gap size" - This option specifies the size of gaps between thumbnails
B. "Ideal thumbnail size" - This option specifies the desired thumbnail size, in area (for example: 40,000 pixels).
How each row is drawn
Here is basically how I would program it...
Starting with the first image in the row, we go through this procedure...
1. First, we find its 'ideal dimensions':
- We calculate what the 'Ideal Width' and 'Ideal Height' of the thumbnail would be, so that its total area = "Ideal Thumbnail Size" (whatever size the user has set it to in the preferences).
2. Next we work out how high the current row would ideally be:
- We take all the 'ideal heights' of the thumbnails so far in the current row and average them. We call this "IdealRowHeight". (Finding the average height means you get a good balance if there are mixture of different shapes in the row).
3. Next we work out the total width of all the thumbnails in the current row:
- We imagine every image in the row is as tall as the "IdealRowHeight", and calculate the total of their widths. We call this figure "TotalWidthOfThumbs".
4. We also work out the average width of the thumbnails in the current row:
- We take "TotalWidthOfThumbs" and divide it by the number of thumbnails in the row. We call this "AverageWidth"
5. Finally, we work out if the current row of thumbnails has grown wider than the screen yet. (If it is wider than the screen, we know it's time to start a new row.)
-We compare the size of these two things:
A) TotalWidthOfThumbs + all the gaps between thumbnails (ie the amount of width this row will need to display)
B) The total width of the screen + ¼ AverageWidth (we allow it to overlap by a quarter of a thumbnail because this is close enough)
If the row is not yet wider than the screen, we go back to stage (1) for the next thumbnail.
If the row is now wider than the screen, the current image is discarded (saved for the next row), and we draw the current row using all the other images so far. The row is drawn by simply setting the height of each thumbnail to = IdealRowHeight x (Screen width - Width of all the gaps) ÷ TotalWidthOfThumbs.
One problem with the thumbnail browser is all the wasted space in the screen: a folder full of landscape pictures has big gaps between each row, while a folder full of portrait pictures has big gaps between each column.
Solution:
A much better way of displaying thumbnails is to make all the thumbnails in each row equal height! (like Google image search does).
Not only is it more attractive, but it gets rid of all the wasted screen space, allowing more thumbnails on screen, and much larger thumbnails.
Here is an image I made to demonstrate the difference:
http://i.imgsafe.org/fb5c94b.png
Edit: another example where the aspect ratios are more mixed:
http://i.imgsafe.org/af48e66.png
I would really love XnView to display thumbnails this way. I would call this option "Dynamic Thumbnails" and turn it on by default.
User Preferences
This option has two user preferences:
A. "Gap size" - This option specifies the size of gaps between thumbnails
B. "Ideal thumbnail size" - This option specifies the desired thumbnail size, in area (for example: 40,000 pixels).
How each row is drawn
Here is basically how I would program it...
Starting with the first image in the row, we go through this procedure...
1. First, we find its 'ideal dimensions':
- We calculate what the 'Ideal Width' and 'Ideal Height' of the thumbnail would be, so that its total area = "Ideal Thumbnail Size" (whatever size the user has set it to in the preferences).
2. Next we work out how high the current row would ideally be:
- We take all the 'ideal heights' of the thumbnails so far in the current row and average them. We call this "IdealRowHeight". (Finding the average height means you get a good balance if there are mixture of different shapes in the row).
3. Next we work out the total width of all the thumbnails in the current row:
- We imagine every image in the row is as tall as the "IdealRowHeight", and calculate the total of their widths. We call this figure "TotalWidthOfThumbs".
4. We also work out the average width of the thumbnails in the current row:
- We take "TotalWidthOfThumbs" and divide it by the number of thumbnails in the row. We call this "AverageWidth"
5. Finally, we work out if the current row of thumbnails has grown wider than the screen yet. (If it is wider than the screen, we know it's time to start a new row.)
-We compare the size of these two things:
A) TotalWidthOfThumbs + all the gaps between thumbnails (ie the amount of width this row will need to display)
B) The total width of the screen + ¼ AverageWidth (we allow it to overlap by a quarter of a thumbnail because this is close enough)
If the row is not yet wider than the screen, we go back to stage (1) for the next thumbnail.
If the row is now wider than the screen, the current image is discarded (saved for the next row), and we draw the current row using all the other images so far. The row is drawn by simply setting the height of each thumbnail to = IdealRowHeight x (Screen width - Width of all the gaps) ÷ TotalWidthOfThumbs.