Documentation ¶
Index ¶
- Constants
- type CaptionRequest
- func (cr *CaptionRequest) BottomTextJSONTag() (string, error)
- func (cr CaptionRequest) CreateHTTPFormBody() (url.Values, error)
- func (cr *CaptionRequest) FontJSONTag() (string, error)
- func (cr *CaptionRequest) MaxFontSizePxJSONTag() (string, error)
- func (cr *CaptionRequest) PasswordJSONTag() (string, error)
- func (cr *CaptionRequest) SetBottomText(bottomText string) *CaptionRequest
- func (cr *CaptionRequest) SetFont(font Font) *CaptionRequest
- func (cr *CaptionRequest) SetMaxFontSize(maxFontSizePx uint) *CaptionRequest
- func (cr *CaptionRequest) SetTopText(topText string) *CaptionRequest
- func (cr *CaptionRequest) TemplateIDJSONTag() (string, error)
- func (cr *CaptionRequest) TextBoxesJSONTag() (string, error)
- func (cr *CaptionRequest) TopTextJSONTag() (string, error)
- func (cr *CaptionRequest) UsernameJSONTag() (string, error)
- type CaptionResponse
- type Font
- type Meme
- type MemesResponse
- type TextBox
- func (t *TextBox) ColorJSONTag() (string, error)
- func (t *TextBox) HeightJSONTag() (string, error)
- func (t *TextBox) OutlineColorTextJSONTag() (string, error)
- func (t *TextBox) SetColor(color uint) *TextBox
- func (t *TextBox) SetHeight(height uint) *TextBox
- func (t *TextBox) SetOutlineColor(outlineColor uint) *TextBox
- func (t *TextBox) SetWidth(width uint) *TextBox
- func (t *TextBox) SetX(x uint) *TextBox
- func (t *TextBox) SetY(y uint) *TextBox
- func (t *TextBox) TextJSONTag() (string, error)
- func (t *TextBox) WidthJSONTag() (string, error)
- func (t *TextBox) XJSONTag() (string, error)
- func (t *TextBox) YJSONTag() (string, error)
Constants ¶
const CaptionMemeEndpoint = "https://api.imgflip.com/caption_image"
const DefaultMaxFontSizePx uint = 50
const GetMemesEndpoint string = "https://api.imgflip.com/get_memes"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CaptionRequest ¶
type CaptionRequest struct { // A template ID as returned by the get_memes response. Any ID that was ever // returned from the get_memes response should work for this parameter. For // custom template uploads, the template ID can be found in the memegenerator // URL, e.g. https://imgflip.com/memegenerator/14859329/Charlie-Sheen-DERP. TemplateID string `schema:"template_id,omitempty" json:"template_id,omitempty"` // Username of a valid imgflip account. This is used to track where API // requests are coming from. Username string `schema:"username,omitempty" json:"username,omitempty"` // Password for the imgflip account. Password string `schema:"password,omitempty" json:"password,omitempty"` // Top text for the meme. Do not use this parameter if you are using the // boxes parameter below. TopText *string `schema:"text0,omitempty" json:"text0,omitempty"` // Bottom text for the meme. Do not use this parameter if you are using the // boxes parameter below. BottomText *string `schema:"text1,omitempty" json:"text1,omitempty"` // [optional] The font family to use for the text Font *Font `schema:"font,omitempty" json:"font,omitempty"` // [optional] Maximum font size in pixels. Defaults to 50px. MaxFontSizePx *uint `schema:"max_font_size,omitempty" json:"max_font_size,omitempty"` // [optional] For creating memes with more than two text boxes, or for further // customization. If TextBoxes is specified, TopText and BototmText will be ignored, // and text will not be automatically converted to uppercase, so you'll have to // handle capitalization yourself if you want the standard uppercase meme text. // The API is currently limited to 20 text boxes per image. The first TextBox in // the list may be left empty so that the second box will automatically be used // as bottom text. TextBoxes []TextBox `schema:"-" json:"boxes,omitempty"` }
func (*CaptionRequest) BottomTextJSONTag ¶
func (cr *CaptionRequest) BottomTextJSONTag() (string, error)
func (CaptionRequest) CreateHTTPFormBody ¶
func (cr CaptionRequest) CreateHTTPFormBody() (url.Values, error)
func (*CaptionRequest) FontJSONTag ¶
func (cr *CaptionRequest) FontJSONTag() (string, error)
func (*CaptionRequest) MaxFontSizePxJSONTag ¶
func (cr *CaptionRequest) MaxFontSizePxJSONTag() (string, error)
func (*CaptionRequest) PasswordJSONTag ¶
func (cr *CaptionRequest) PasswordJSONTag() (string, error)
func (*CaptionRequest) SetBottomText ¶
func (cr *CaptionRequest) SetBottomText(bottomText string) *CaptionRequest
func (*CaptionRequest) SetFont ¶
func (cr *CaptionRequest) SetFont(font Font) *CaptionRequest
func (*CaptionRequest) SetMaxFontSize ¶
func (cr *CaptionRequest) SetMaxFontSize(maxFontSizePx uint) *CaptionRequest
func (*CaptionRequest) SetTopText ¶
func (cr *CaptionRequest) SetTopText(topText string) *CaptionRequest
func (*CaptionRequest) TemplateIDJSONTag ¶
func (cr *CaptionRequest) TemplateIDJSONTag() (string, error)
func (*CaptionRequest) TextBoxesJSONTag ¶
func (cr *CaptionRequest) TextBoxesJSONTag() (string, error)
func (*CaptionRequest) TopTextJSONTag ¶
func (cr *CaptionRequest) TopTextJSONTag() (string, error)
func (*CaptionRequest) UsernameJSONTag ¶
func (cr *CaptionRequest) UsernameJSONTag() (string, error)
type CaptionResponse ¶
type CaptionResponse struct { Success bool `json:"success,omitempty"` Data struct { URL string PageURL string } `json:"data,omitempty"` ErrorMsg string `json:"error_message,omitempty"` }
func CaptionImage ¶
func CaptionImage(req *CaptionRequest) (CaptionResponse, error)
CaptionImage wraps the caption_image endpoint. It makes a request using the provided parameters, and will return an error if something goes wrong at any point during the process. The errors can come originate in Go or be from the API, depending on where the failure occurred. This was done so that the caller does not have to check both the returned error value, AND CaptionResponse.Success. If the API returns an error, it will be reflected in both CaptionResponse.ErrorMsg and in the returned Go error.
type Meme ¶
type Meme struct { ID string `json:"id,omitempty"` Name string `json:"name,omitempty"` URL string `json:"url,omitempty"` Width uint `json:"width,omitempty"` Height uint `json:"height,omitempty"` // BoxCount describes the number of text boxes the Meme uses. BoxCount uint `json:"box_count,omitempty"` }
type MemesResponse ¶
type MemesResponse struct { Success bool `json:"success,omitempty"` Data struct { Memes []Meme `json:"memes,omitempty"` } `json:"data,omitempty"` }
func GetMemesWithResponse ¶
func GetMemesWithResponse() (*MemesResponse, error)
type TextBox ¶
type TextBox struct { // Text to be displayed Text string `json:"text,omitempty"` // [optional] X coord of of the top left corner of the TextBox // If specified, must also specify Y, Width, Height X *uint `json:"x,omitempty"` // [optional] Y coord of of the top left corner of the TextBox // If specified, must also specify X, Width, Height Y *uint `json:"y,omitempty"` // [optional] width of the TextBox // If specified, must also specify X, Y, Height Width *uint `json:"width,omitempty"` // [optional] height of the TextBox // If specified, must also specify X, Y, Width Height *uint `json:"height,omitempty"` // [optional] Hex color for Text Color *uint `json:"color,omitempty"` // [optional] Hex color for Text outline OutlineColor *uint `json:"outline_color,omitempty"` }
TextBox specifies parameters for a CaptionReqeust TextBox. any [optional] parameters that are not set will default to settings provided by imgflip.com/memegenerator.