In researching this I saw nothing that would appear to allow for this natively within feh. The montage switch is the closest but it doesn't allow for any dynamic sizing, merely just displays a montage based on the -H and -W switches.
Given this I feel the best approach would be something like this:
$ cat fehm.bash
#!/bin/bash
gridW=5
gridH=6
file=(*.jpg)
W=$(identify -ping -format '%w' $file)
H=$(identify -ping -format '%h' $file)
LW=$(($W * $gridW))
LH=$(($H * ($gridH + 1)))
feh -i --index-info '' --thumb-width $W --thumb-height $H \
--limit-width $LW --limit-height $LH .
# --index-info format
# Show image information based on format below thumbnails in
# index / thumbnail mode. See FORMAT SPECIFIERS. May contain
# newlines. Use "--index-info ''" to display thumbnails without
# any info text
#
# Note: If you specify image-related formats (such as %w or
# %s), feh needs to load all images to calculate the dimensions
# of its own window. So when using them with many files, it
# will take a while before a feh window becomes visible. Use
# --preload to get a progress bar.
#
# -i, --index
# Enable Index mode. Index mode is similar to montage mode,
# and accepts the same options. It creates an index print of
# thumbnails, printing the image name beneath each thumbnail.
# Index mode enables certain other options, see INDEX AND
# THUMBNAIL MODE OPTIONS and MONTAGE MODE OPTIONS.
#
# -H, --limit-height pixels
# Limit the height of the montage.
#
# -W, --limit-width pixels
# Limit the width of the montage, defaults to 800 pixels.
#
# If both --limit-width and --limit-height are specified, the
# montage will be exactly width x height pixels in dimensions.
#
# -E, --thumb-height pixels
# Set thumbnail height.
#
# -y, --thumb-width pixels
# Set thumbnail width.
The above could be incorporated into a Bash function instead if you don't want to have to have a script:
$ cat fehm_func.bash
fehm () {
gridW=5
gridH=6
file=(*.jpg)
W=$(identify -ping -format '%w' $file)
H=$(identify -ping -format '%h' $file)
LW=$(($W * $gridW))
LH=$(($H * ($gridH + 1)))
feh -i --index-info '' --thumb-width $W --thumb-height $H \
--limit-width $LW --limit-height $LH .
}
You simply source the above like this:
$ . fehm_func.bash
$ fehm
Modification
One thing I noticed while doing this was that your original example didn't appear to work. The setting of the grid to 5x6 would result in only a 5x5. This appears to be due to the space in between the rows of images. To work around this I padded the $gridH calculation by adding a 1 to it, effectively making it 5x7.
LH=$(($H * ($gridH + 1)))
Example run
With the above in place. I used the following script to construct some sample data. The data is comprised of images identical to your size, 300x75 and they alternative between blue and red, to help in seeing the effects of the solution I'm providing.
$ for i in {01..30};do int=$(expr $i); [ $((int%2)) -eq 0 ] && c=blue || \
c=red; convert -size 300x75 xc:${c} img${i}.jpg;done
Results in this set of files:
$ ls | column -c 80
img01.jpg img07.jpg img13.jpg img19.jpg img25.jpg
img02.jpg img08.jpg img14.jpg img20.jpg img26.jpg
img03.jpg img09.jpg img15.jpg img21.jpg img27.jpg
img04.jpg img10.jpg img16.jpg img22.jpg img28.jpg
img05.jpg img11.jpg img17.jpg img23.jpg img29.jpg
img06.jpg img12.jpg img18.jpg img24.jpg img30.jpg
With the above data, now if we use our fehm function:
$ fehm

References
-tile MxNx0x0 out.jpg`
– eqzx Feb 13 '19 at 20:37