aboutsummaryrefslogtreecommitdiffstats
path: root/ils.go
diff options
context:
space:
mode:
Diffstat (limited to 'ils.go')
-rw-r--r--ils.go29
1 files changed, 17 insertions, 12 deletions
diff --git a/ils.go b/ils.go
index 05ece82..71701c9 100644
--- a/ils.go
+++ b/ils.go
@@ -204,19 +204,24 @@ func thumbnailFiles(w io.Writer, imagePaths []string, width, rowWidth, cellX, ce
rowImages[i] = make(chan image.Image, 1)
}
errCh := make(chan error, 1)
- for i, row := range rows {
- go func() {
- img, err := compositeImageRow(row, width*cellX, rowWidth*cellX, cellX, aspectRatio)
- if err != nil {
- select {
- case errCh <- err:
- default:
+ go func() {
+ sem := make(chan struct{}, 20)
+ for i, row := range rows {
+ sem <- struct{}{}
+ go func() {
+ defer func() { <-sem }()
+ img, err := compositeImageRow(row, width*cellX, rowWidth*cellX, cellX, aspectRatio)
+ if err != nil {
+ select {
+ case errCh <- err:
+ default:
+ }
+ return
}
- return
- }
- rowImages[i] <- img
- }()
- }
+ rowImages[i] <- img
+ }()
+ }
+ }()
for i, row := range rows {
thisRowWidth := 0
for j, filename := range row {