Skip to content

Commit

Permalink
sort files by name before processing
Browse files Browse the repository at this point in the history
  • Loading branch information
danielchristianschroeter committed Sep 16, 2023
1 parent 97b2a28 commit 6af7d05
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# watermark-to-image

Watermark-to-Image is a command-line application for inserting watermarks into the lower right corner of images located in a specified folder. It supports various customization options.
Watermark-to-Image is a command-line application for inserting watermarks into images located in a specified folder. It supports various customization options.

## Table of Contents

Expand Down Expand Up @@ -41,7 +41,7 @@ $ go build .

## Command Line Parameters

The application supports various command-line parameters for customization. Here is a list of available parameters:
The application supports various command-line parameters for customization. Here is a list of all available parameters:

```shell
./watermark-to-image --help
Expand All @@ -50,7 +50,7 @@ The application supports various command-line parameters for customization. Here
-targetDirectory string
Set the target directory for watermarked images (required).
-targetWatermarkedImageFilename string
Rename all target files to the specified filename. Requires 'targetWatermarkedImageExtension' to be set.
Rename all target files to the specified filename.
-targetWatermarkedImageFilenameSuffix string
Set the dynamic suffix for the filename defined in 'targetWatermarkedImageFilename'. Allowed values are '3DIGITSCOUNT' (3-digit enumeration count) or 'RAND' (random 6-digit number). Default is '3DIGITSCOUNT'. (default "3DIGITSCOUNT")
-targetWatermarkedImageHeight int
Expand All @@ -74,6 +74,7 @@ The application supports various command-line parameters for customization. Here
## Download Executables
You can download prebuilt executables for various operating systems from the [Releases](https://github.com/danielchristianschroeter/watermark-to-image/releases) page.
_Note for macOS users: Due to the application not being officially signed, it may need to be manually approved under your system's security settings._
## License
Expand Down
8 changes: 7 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"math/rand"
"os"
"path/filepath"
"sort"
"strconv"
"strings"

Expand Down Expand Up @@ -52,7 +53,7 @@ func init() {
flag.IntVar(&targetWatermarkedImageMaxDimension, "targetWatermarkedImageMaxDimension", 0, "Specify the maximum dimension size for the target watermarked image. Use 0 to maintain the aspect ratio. Default is 0.")
flag.IntVar(&targetWatermarkedImageWidth, "targetWatermarkedImageWidth", 0, "Resize the target watermarked image to the specified width (in pixels). Aspect ratio will be preserved if 'targetWatermarkedImageHeight' is empty.")
flag.IntVar(&targetWatermarkedImageHeight, "targetWatermarkedImageHeight", 0, "Resize the target watermarked image to the specified height (in pixels). Aspect ratio will be preserved if 'targetWatermarkedImageWidth' is empty.")
flag.StringVar(&targetWatermarkedImageFilename, "targetWatermarkedImageFilename", "", "Rename all target files to the specified filename. Requires 'targetWatermarkedImageExtension' to be set.")
flag.StringVar(&targetWatermarkedImageFilename, "targetWatermarkedImageFilename", "", "Rename all target files to the specified filename.")
flag.StringVar(&targetWatermarkedImageFilenameSuffix, "targetWatermarkedImageFilenameSuffix", "3DIGITSCOUNT", "Set the dynamic suffix for the filename defined in 'targetWatermarkedImageFilename'. Allowed values are '3DIGITSCOUNT' (3-digit enumeration count) or 'RAND' (random 6-digit number). Default is '3DIGITSCOUNT'.")
}

Expand Down Expand Up @@ -96,6 +97,11 @@ func main() {
log.Fatal(err)
}

// Sort the files by name
sort.Slice(files, func(i, j int) bool {
return files[i].Name() < files[j].Name()
})

// Set a count
count := 1

Expand Down

0 comments on commit 6af7d05

Please sign in to comment.