Package bulk has functions to load and save image metadata to a CSV file as needed by the 'Bulk Add CSV' Shimmie2 extension. The CSV file is assumed to have the following format:
"/path/to/image.jpg","spaced tags","source","rating s/q/e","/path/thumbnail.jpg"
The last record (thumbnail) is left empty as thumbnails can easily be generated by the server.
The package assumes that all images and the CSV file are under a certain directory path that is used as input in many package functions.
Combine takes the metadata of imagesWithInfo and copies them to images returning the combined result.
CurrentPrefix reads from an open CSV file, reads the first line and uses the base directory of the provided workingDir path to find the path prefix used in the CSV file.
As an example if the provided workingDir path is '/localpath/pics' and the first line has '/serverpath/pics/pic1' then the returned current prefix will be '/serverpath'.
LoadCSV loads the image metadata from a CSV file that is open for reading. The metadata are returned as slice of images and should be combined with the slice of images discovered by LoadImages by calling Combine.
LoadImages expects a slice of directory entries (os.FileInfo) which is the result of a read directory like ioutil.ReadDir. It loops through the slice, ignoring any directory and keeps only the files with one of the following extensions: "gif", "jpeg", "jpg", "png", "swf"
It returns a slice of images without metadata, using the filename as Name and the order the files were found as an increasing ID starting from 0.
In case of a CSV file, the image metadata should be read using LoadCSV and then combined with the images (discovered by LoadImages) using Combine.
Save will write the image metadata to an open for writing file. It will keep the base of the dir path and replace the prefix with the provided one.
Image holds the metadata of each image from the CSV file.
FindByID takes a slice of images, sorts them by ID and then finds then one with ID id.