Skip to content

Commit

Permalink
Merge pull request #93 from zalando-stups/strip-metadata-from-images
Browse files Browse the repository at this point in the history
#92 adding environment variable for stripping meta…
  • Loading branch information
rgritti authored Apr 10, 2018
2 parents 73eeca1 + e33c9c1 commit 59b76fe
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,15 @@ Because of performance, each filter does not trigger a transformation of the ima
the result of the previous filters. The image is actually transformed every time the filter cannot be merged with the
previous one e.g. both edit the same attribute and also at the end of the filter chain by the finalizeResponse filter.

## Metadata
By default metadata are kept in the processed images. If you are not interested in metadata and
you want them stripped from all the images that are processed, you can add the following
environment variable to the running system:

```
STRIP_METADATA=TRUE
```

## Packaging
In order to package skrop for production, you're going to need [Docker](https://docs.docker.com).
To build a Docker image, just run the build script (the arguments are optional):
Expand Down
11 changes: 11 additions & 0 deletions filters/imagefilter.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
"gopkg.in/h2non/bimg.v1"
"io/ioutil"
"net/http"
"os"
"strings"
)

const (
Expand All @@ -34,6 +36,7 @@ const (
var (
cropTypeToGravity map[string]bimg.Gravity
cropTypes map[string]bool
stripMetadata bool
)

func init() {
Expand All @@ -49,6 +52,11 @@ func init() {
East: bimg.GravityEast,
West: bimg.GravityWest,
Center: bimg.GravityCentre}

val, exists := os.LookupEnv("STRIP_METADATA")
if (exists && strings.ToUpper(val) == "TRUE") {
stripMetadata = true
}
}

// ImageFilter defines what a filter should implement
Expand Down Expand Up @@ -192,6 +200,9 @@ func transformImage(image *bimg.Image, opts *bimg.Options) ([]byte, error) {
}

func applyDefaults(o *bimg.Options) *bimg.Options {
if (stripMetadata) {
o.StripMetadata = true
}
if o.Quality == 0 {
o.Quality = Quality
}
Expand Down

0 comments on commit 59b76fe

Please sign in to comment.