Documentation
¶
Index ¶
- Constants
- type GatherPicturesProcessFunc
- type PictureBook
- func (pb *PictureBook) AddBlankPage(ctx context.Context, pagenum int) error
- func (pb *PictureBook) AddPicture(ctx context.Context, pagenum int, pic *picture.PictureBookPicture) error
- func (pb *PictureBook) AddPictures(ctx context.Context, paths []string) error
- func (pb *PictureBook) AddText(ctx context.Context, pagenum int, pic *picture.PictureBookPicture) error
- func (pb *PictureBook) GatherPictures(ctx context.Context, paths []string) ([]*picture.PictureBookPicture, error)
- func (pb *PictureBook) Save(ctx context.Context, path string) error
- type PictureBookBorders
- type PictureBookCanvas
- type PictureBookMargins
- type PictureBookOptions
- type PictureBookText
Constants ¶
const MM2INCH float64 = 25.4
MM2INCH defines the number if millimeters in an inch.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GatherPicturesProcessFunc ¶ added in v0.5.2
type GatherPicturesProcessFunc defines a method for processing the path to an image file in to a `picture.PictureBookPicture` instance.
func DefaultGatherPicturesProcessFunc ¶ added in v0.5.2
func DefaultGatherPicturesProcessFunc(pb_opts *PictureBookOptions) (GatherPicturesProcessFunc, error)
DefaultGatherPicturesProcessFunc returns a default GatherPicturesProcessFunc used to derive a `picture.PictureBookPicture` instance
from the path to an image file. It applies any filters and transformation processes and derives caption data per settings defined in 'pb_opts'.
type PictureBook ¶
type PictureBook struct {
// A `fpdf.Fpdf` instance used to produce the picturebook PDF file.
PDF *fpdf.Fpdf
// A `sync.Mutex` instance used to add images in an orderly fashion.
Mutex *sync.Mutex
// The `PictureBookBorders` definition to use for this picturebook
Borders *PictureBookBorders
// The `PictureBookMargins` definition to use for this picturebook
Margins *PictureBookMargins
// The `PictureBookCanvas` definition to use for this picturebook
Canvas PictureBookCanvas
// The `PictureBookText` definition to use for this picturebook
Text PictureBookText
// The `PictureBookOptions` used to create this picturebook
Options *PictureBookOptions
// The `GatherPicturesProcessFunc` function used to determine whether an image is included in a picturebook
ProcessFunc GatherPicturesProcessFunc
// contains filtered or unexported fields
}
type PictureBook provides a struct for creating a PDF file from a folder of images (a picturebook).
func NewPictureBook ¶
func NewPictureBook(ctx context.Context, opts *PictureBookOptions) (*PictureBook, error)
NewPictureBook returns a new `PictureBook` instances configured according to the settings in 'opts'.
func (*PictureBook) AddBlankPage ¶ added in v0.4.7
func (pb *PictureBook) AddBlankPage(ctx context.Context, pagenum int) error
AddBlankPage add a blank page the final PDF document at page 'pagenum'.
func (*PictureBook) AddPicture ¶
func (pb *PictureBook) AddPicture(ctx context.Context, pagenum int, pic *picture.PictureBookPicture) error
func (*PictureBook) AddPictures ¶
func (pb *PictureBook) AddPictures(ctx context.Context, paths []string) error
AddPictures adds images founds in one or more folders defined 'paths' to the picturebook instance.
func (*PictureBook) AddText ¶ added in v0.8.0
func (pb *PictureBook) AddText(ctx context.Context, pagenum int, pic *picture.PictureBookPicture) error
AddText add the value of `pic.Text` on the adjacent page to `pic`.
func (*PictureBook) GatherPictures ¶ added in v0.2.0
func (pb *PictureBook) GatherPictures(ctx context.Context, paths []string) ([]*picture.PictureBookPicture, error)
GatherPictures collects all the images in one or more folders defined by 'paths' and returns a list of `picture.PictureBookPicture` instances.
type PictureBookBorders ¶ added in v0.4.9
type PictureBookBorders struct {
// The size of any border to add to the top of each image.
Top float64
// The size of any border to add to the bottom of each image.
Bottom float64
// The size of any border to add to the left-hand side of each image.
Left float64
// The size of any border to add to the right-hand side of each image.
Right float64
}
type PictureBookBorders defines a struct for storing borders to be applied to a images in a picturebook.
type PictureBookCanvas ¶
type PictureBookCanvas struct {
// The width of the internal picturebook canvas.
Width float64
// The height of the internal picturebook canvas.
Height float64
}
type PictureBookCanvas defines a struct for storing canvas information for a picturebook.
type PictureBookMargins ¶ added in v0.4.9
type PictureBookMargins struct {
// The size of any margin to add to the top of each page.
Top float64
// The size of any margin to add to the bottom of each page.
Bottom float64
// The size of any margin to add to the left-hand side of each page.
Left float64
// The size of any margin to add to the right-hand side of each page.
Right float64
}
type PictureBookMargins defines a struct for storing margins to be applied to a picturebook
type PictureBookOptions ¶
type PictureBookOptions struct {
// The orientation of the final picturebook. Valid options are "P" and "L" for portrait and landscape respectively.
Orientation string
// A string label corresponding to known size. Valid options are "a1", "a2", "a3", "a4", "a5", "a6", "a7", "letter", "legal" and "tabloid".
Size string
// The width of the final picturebook.
Width float64
// The height of the final picturebook.
Height float64
// The unit of measurement to use for the `Width` and `Height` options.
Units string
// The number dots per inch to use when calculating the size of the final picturebook. Valid options are "inches", "centimeters", "millimeters".
DPI float64
// The size of any border to apply to each image in the final picturebook.
Border float64
// The size of any additional bleed to apply to the final picturebook.
Bleed float64
// The size of any margin to add to the top of each page.
MarginTop float64
// The size of any margin to add to the bottom of each page.
MarginBottom float64
// The size of any margin to add to the left-hand side of each page.
MarginLeft float64
// The size of any margin to add to the right-hand side of each page.
MarginRight float64
// An optional `filter.Filter` instance used to determine whether or not an image should be included in the final picturebook.
Filter filter.Filter
// Zero or more optional `process.Process` instance used to transform images being included in the final picturebook.
PreProcess process.Process
// Zero or more optional `process.Process` instance used to transform images after having been rotated to fill the page and before being included in the final picturebook.
RotateToFillPostProcess process.Process
// An optional `caption.Caption` instance used to derive a caption string for each image added to the final picturebook.
Caption caption.Caption
// An optional `text.Text` instance used to derive a text string for each image added to the final picturebook.
Text text.Text
// An optional `sort.Sorter` instance used to sort images before they are added to the final picturebook.
Sort sort.Sorter
// A boolean value signaling that an image should be rotated if necessary to fill the maximum amount of any given page.
FillPage bool
// A boolean value to enable verbose logging during the creation of a picturebook.
Verbose bool
// A boolean value to enable to use of an OCRA font for writing captions.
OCRAFont bool
// A `aaronland/go-picturebook/bucket.Bucket` instance where picturebook data is read from.
Source bucket.Bucket
// A `aaronland/go-picturebook/bucket.Bucket` instance where the final picturebook is written to.
Target bucket.Bucket
// A `aaronland/go-picturebook/bucket.Bucket` instance where the temporary files necessary in the creation of the picturebook are written to.
Temporary bucket.Bucket
// A `aaronland/go-picturebook/progress.Monitor` instance used to signal picturebook creation progress.
Monitor progress.Monitor
// A boolean value signaling that images should only be added on even-numbered pages.
EvenOnly bool
// A boolean value signaling that images should only be added on odd-numbered pages.
OddOnly bool
// An optional value to indicate that a picturebook should not exceed this number of pages
MaxPages int
}
PictureBookOptions defines a struct containing configuration information for a given picturebook instance.
func NewPictureBookDefaultOptions ¶
func NewPictureBookDefaultOptions(ctx context.Context) (*PictureBookOptions, error)
NewPictureBookDefaultOptions returns a `PictureBookOptions` with default settings.
type PictureBookText ¶
type PictureBookText struct {
// The name of the font to use for text strings.
Font string
// The style of the font to use for text strings.
Style string
// The size of the font to use for text strings.
Size float64
// The margin to apply to text strings.
Margin float64
// The colour of the font to use for text strings.
Colour []int
}
type PictureBookText defines a struct for storing information for how text should be displayed in a picturebook.
Directories
¶
| Path | Synopsis |
|---|---|
|
app
|
|
|
picturebook
package picturebook provides a command-line application for creating picturebooks.
|
package picturebook provides a command-line application for creating picturebooks. |
|
package caption provides a common interface for different mechanisms to derive captions for images.
|
package caption provides a common interface for different mechanisms to derive captions for images. |
|
cmd
|
|
|
picturebook
command
picturebook is a command-line application for creating a PDF file from a folder containing images.
|
picturebook is a command-line application for creating a PDF file from a folder containing images. |
|
package filter provides a common interfaces for filtering mechanisms used to determine inclusion in a picturebook.
|
package filter provides a common interfaces for filtering mechanisms used to determine inclusion in a picturebook. |
|
package picture provides methods and data structures for internal representations of images.
|
package picture provides methods and data structures for internal representations of images. |
|
package process provides a common interfaces for manipulating images before adding them to a picturebook.
|
package process provides a common interfaces for manipulating images before adding them to a picturebook. |
|
package sort provides a common interface for sorting a list of images to be included in a picturebook.
|
package sort provides a common interface for sorting a list of images to be included in a picturebook. |
|
package tempfile provides methods for working with temporary files used to create a picturebook.
|
package tempfile provides methods for working with temporary files used to create a picturebook. |
|
package text provides a common interface for different mechanisms to derive texts for images.
|
package text provides a common interface for different mechanisms to derive texts for images. |