aeimagesflags

package module
v0.0.0-...-eed2909 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2015 License: BSD-2-Clause Imports: 3 Imported by: 2

README

aeimagesflags

This project lets you use the undocumented flags of the App Engine Images service URLs to serve transformed images.

Documentation

GoDoc

Usage example

package example

import (
  "fmt"

  "github.com/ernestoalejo/aeimagesflags"
  "google.golang.org/appengine"
  "google.golang.org/appengine/images"
)

func demo(blobKey appengine.BlobKey) error {
  url, err := images.CreateServingURL(blobKey, nil)
  if err != nil {
    return err
  }

  flags := aeimagesflags.Flags{
    Width: 300,
    Height: 100,
    Crop: true,
  }
  fmt.Println(aeimagesflags.Apply(url.String(), flags))

  return nil
}

License

Copyright (c) 2015, Ernesto Alejo
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
  list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice,
  this list of conditions and the following disclaimer in the documentation
  and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Documentation

Overview

Package aeimagesflags lets you use the undocumented flags of the App Engine Images service URLs to serve transformed images.

Most of the flags are extracted from the answer to this question:

http://stackoverflow.com/questions/25148567/list-of-all-the-app-engine-images-service-get-serving-url-uri-options

As mentioned there these flags are not documented; Google could remove most of them without notice at any time.

Index

Constants

View Source
const (
	Rotate90  = rotation(90)
	Rotate180 = rotation(180)
	Rotate270 = rotation(270)
)

Variables

This section is empty.

Functions

func Apply

func Apply(URL string, flags Flags) string

Apply takes the serving URL (generated using appengine/images.ServingURL) and apply the flags to it returning the full URL to use.

Types

type Flags

type Flags struct {
	// Size of the largest dimension
	Size uint64

	// Serve the original image
	Original bool

	Width  uint64
	Height uint64

	// Smart square crop that attempts cropping to faces
	SmartSquareCropFaces bool

	// Alternative smart square crop
	SmartSquareCrop bool

	CircularCrop bool

	SquareCrop bool

	// Like square crop but it's sometimes above the image half, like ~33% of the
	// vertical height or so.
	TranslatedSquareCrop bool

	// Crop to the smallest of: Width, Height or Size
	SmallestCrop bool

	// Flip the image on its axis
	VerticalFlip, HorizontalFlip bool

	Rotate rotation

	// Force specific image formats.
	// Forcing PNG, WebP and GIF outputs can work in combination with circular
	// crops for a transparant background. Forcing JPG can be combined with border
	// color to fill in backgrounds in transparent images.
	ForceJPEG, ForcePNG bool
	ForceWebP, ForceGIF bool

	// Generate MP4 from input animated GIF
	MP4 bool

	// Remove any animation of the GIF file
	KillAnimation bool

	// Width of the border, in pixels
	Border uint64

	// Color of the border, black by default (transparent defaults to 255)
	BorderColor color.RGBA

	// Add header to force browser download of the image
	ForceDownload bool

	// Set Cache-Control max-age directive to these number of days
	ExpiresDays uint64

	// Change the quality of the JPEG output
	JPEGQuality uint64

	// Intensity of the blur (max 100)
	Blur uint64

	// Size of the border gradient
	BorderGradientSize uint64

	// Color of the border gradient
	BorderGradientColor color.RGBA
}

Jump to

Keyboard shortcuts

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