gallery

package module
v0.0.0-...-408de54 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 7, 2018 License: GPL-3.0 Imports: 12 Imported by: 0

README

gallery is a program to create a static photo gallery website.

You provide it a list of filenames and metadata about each, and where the files are located. It generates HTML for a static site, and resizes the images to create thumbnails as needed.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Album

type Album struct {
	// Name.
	Name string

	// File describing images in the album.
	File string

	// Dir containing the original images.
	OrigImageDir string

	// Dir to install HTML/images.
	InstallDir string

	// Subdirectory we will be in in the installation directory. We use this when
	// creating the link/image when creating the gallery index page. If you are
	// not building a gallery with multiple albums, then we don't use this field.
	InstallSubDir string

	// The thumbnail size in pixels. Width and height are the same.
	ThumbnailSize int

	// The size of the larger version of images (if the original image is larger
	// than this) in pixels. This is the pixel size set of the longest side.
	LargeImageSize int

	// How many images per page.
	PageSize int

	// Number of workers to use in resizing images.
	Workers int

	// Whether to log verbosely.
	Verbose bool

	// Whether to generate/link zip of images.
	IncludeZip bool

	// If true, we copy over the original images and link to each from the "large"
	// image (the single image pages).
	//
	// If false, we don't, and the large image is not a link.
	IncludeOriginals bool

	// Force generation of images (e.g. thumbs) even if they exist.
	ForceGenerateImages bool

	// Force generation of HTML even if it exists.
	ForceGenerateHTML bool

	// Force generation of Zips even if they exist.
	ForceGenerateZip bool

	// Gallery's name. Human readable.
	//
	// The gallery is the name given to the site holding potentially multiple
	// albums of images. We use it inside the album when linking back to the top
	// level of the gallery. If you are creating only a single album, then we do
	// not use this field.
	GalleryName string

	// Tags tells us to include images that has one of these tags. If there are
	// no tags specified, then include all images.
	Tags []string
	// contains filtered or unexported fields
}

Album holds information about an album of images.

func (*Album) ChooseImages

func (a *Album) ChooseImages() error

ChooseImages decides which images we will include when we build the HTML.

The basis for this choice is whether the image has one of the requested tags or not.

func (*Album) GenerateHTML

func (a *Album) GenerateHTML() error

GenerateHTML does just that!

Split over several pages if necessary.

func (*Album) GenerateImages

func (a *Album) GenerateImages() error

GenerateImages creates smaller images than the original ones for use in the HTML page.

This includes one that is a large size (but still usually smaller than the original).

We also generate thumbnails.

We only generate images if the target does not yet exist (unless asked to do so).

We only look at chosen images.

func (*Album) GetThumb

func (a *Album) GetThumb() *Image

GetThumb picks a thumbnail to represent the album.

func (*Album) Install

func (a *Album) Install() error

Install loads image information, and then chooses, resizes, builds HTML, and installs the HTML and images.

func (*Album) InstallOriginalImages

func (a *Album) InstallOriginalImages() error

InstallOriginalImages copies the chosen images into the install directory.

type Gallery struct {
	// File describing the gallery and its albums.
	File string

	// Directory where we output including images and HTML.
	InstallDir string

	// Name of the gallery.
	Name string

	// Whether to log verbosely.
	Verbose bool

	// Whether to generate/link zips of images.
	IncludeZips bool

	// See description of this option in Album.
	IncludeOriginals bool

	// Force generation of images (e.g. thumbs) even if they exist.
	ForceGenerateImages bool

	// Force generation of HTML even if it exists.
	ForceGenerateHTML bool

	// Force generation of Zips even if they exist.
	ForceGenerateZip bool

	// Number of image thumbnails per page in albums.
	PageSize int

	// Number of workers to use in resizing images.
	Workers int

	// See definition in Album.
	ThumbnailSize int

	// See definition in Album.
	LargeImageSize int
	// contains filtered or unexported fields
}

Gallery holds information about a full gallery site which contains 1 or more albums of images.

func (*Gallery) Install

func (g *Gallery) Install() error

Install loads gallery/albums information. It then resizes the images as needed, and generates and installs the HTML/images.

type HTMLAlbum

type HTMLAlbum struct {
	URL      string
	ThumbURL string
	Name     string
}

HTMLAlbum holds info needed in HTML about an album.

type HTMLImage

type HTMLImage struct {
	IncludeOriginals bool
	OriginalImageURL string
	FullImageURL     string
	ThumbImageURL    string
	Description      string
	Index            int
}

HTMLImage holds image info needed in HTML.

type Image

type Image struct {
	// Full path to the image.
	Path string

	// Image's base filename.
	Filename string

	// Human readable description of the image.
	Description string

	// Tags assigned to the image.
	Tags []string

	// Size for the thumbnail. Height/width in pixels.
	ThumbnailSize int

	// Size for the larger version of the image (which is still likely smaller
	// than the original image). Maximum of width/height in pixels.
	LargeImageSize int

	// Path to the thumbnail.
	ThumbnailPath string

	// Basename of the thumbnail.
	ThumbnailFilename string

	// Path to the larger version of the image.
	LargeImagePath string

	// Basename of the larger version of the image.
	LargeImageFilename string
}

Image holds image information from the metadata file.

func ParseAlbumFile

func ParseAlbumFile(file string) ([]*Image, error)

ParseAlbumFile an album file. This file lists images and information about each of them.

Format of the file: Image filename\n Optional: Description\n Optional: Tag: comma separated tags on the image\n Blank line Then should come the next filename, or end of file.

This means each block describes information about one file.

We parse into Image structs. We parse only these fields: Filename Description Tags

This is to allow this function to be usable for operating on the album file by itself without assuming we are doing anything with it.

func (Image) String

func (i Image) String() string

Directories

Path Synopsis
cmd
addimages
This program helps you add images to an existing album.
This program helps you add images to an existing album.
makegallery
This program creates a gallery website.
This program creates a gallery website.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL