Skip to content

Commit

Permalink
feat: unit tests form exract
Browse files Browse the repository at this point in the history
  • Loading branch information
aldor007 committed Apr 21, 2019
1 parent 4d2ce5c commit 8669ca9
Show file tree
Hide file tree
Showing 17 changed files with 385 additions and 175 deletions.
10 changes: 5 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ FROM ubuntu:18.04 as builder

# ENV LIBVIPS_VERSION 8.7.3
ENV LIBVIPS_VERSION 8.6.2
ENV DEP_VERSION v0.5.0
ENV GOLANG_VERSION 1.11
ENV DEP_VERSION v0.5.1
ENV GOLANG_VERSION 1.12.1

# Installs libvips + required libraries
RUN \
Expand Down Expand Up @@ -39,16 +39,16 @@ RUN curl -fsSL --insecure "$GOLANG_DOWNLOAD_URL" -o golang.tar.gz \
&& tar -C /usr/local -xzf golang.tar.gz \
&& rm golang.tar.gz

ENV GOPATH /go
# ENV GOPATH /go
ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH
# ENV GOROOT /go:$GOROOT

RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 777 "$GOPATH"
WORKDIR $GOPATH
RUN curl -fsSL -o /usr/local/bin/dep https://github.com/golang/dep/releases/download/$DEP_VERSION/dep-linux-amd64 && chmod +x /usr/local/bin/dep
# RUN curl -fsSL -o /usr/local/bin/dep https://github.com/golang/dep/releases/download/$DEP_VERSION/dep-linux-amd64 && chmod +x /usr/local/bin/dep
ADD . /go/src/github.com/aldor007/mort

RUN cd /go/src/github.com/aldor007/mort && dep ensure -vendor-only
# RUN cd /go/src/github.com/aldor007/mort && dep ensure -vendor-only
RUN cd /go/src/github.com/aldor007/mort; go build -o /go/mort cmd/mort/mort.go;

FROM ubuntu:18.04
Expand Down
7 changes: 7 additions & 0 deletions cmd/mort/mort.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,13 @@ func configureMonitoring(mortConfig *config.Config) {
[]string{"method", "storage"},
))

p.RegisterCounterVec("storage_request", prometheus.NewCounterVec(prometheus.CounterOpts{
Name: "mort_storage_request",
Help: "mort requests storage",
},
[]string{"method", "bucket", "storage", "object_type"},
))

p.RegisterCounter("collapsed_count", prometheus.NewCounter(prometheus.CounterOpts{
Name: "mort_request_collapsed_count",
Help: "mort count of collapsed requests",
Expand Down
8 changes: 7 additions & 1 deletion doc/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,13 @@ Server section describe configuration for HTTP server and some runtime variables
server:
listen: "0.0.0.0:8080" # default traffic listener
monitoring: "" # default no monitoring ( or prometheus)
cacheSize: 10 # default size of cache used for new images
cache:
type: "memory" # default or redis
maxCacheItemSizeMB: 50 # max item size to cache default 5 MB
# config for redis
address:
- "localhost:6379"
clientConfig: # change redis instance config
requestTimeout: 70 # default request timeout in seconds
internalListen: "0.0.0.0:8081" # default listener for debug /debug and metrics /metrics
plugins: # list of additional plugins
Expand Down
64 changes: 60 additions & 4 deletions doc/Image-Operations.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,18 @@ Table of contents
* [Crop](#crop)
+ [Preset](#preset-4)
+ [Query string](#query-string-4)
* [Watermark](#watermark)
* [Extract](#extract)
+ [Preset](#preset-5)
+ [Query string](#query-string-5)
* [Image format](#image-format)
* [ResizeCropAuto](#resizeCropAuto)
+ [Preset](#preset-6)
+ [Query string](#query-string-6)
* [Watermark](#watermark)
+ [Preset](#preset-7)
+ [Query string](#query-string-7)
* [Image format](#image-format)
+ [Preset](#preset-8)
+ [Query string](#query-string-8)

## Originals

Expand Down Expand Up @@ -176,13 +182,63 @@ Position can be one of:

</br>

<a href="https://mort.mkaciuba.com/demo/img.jpg?operation=crop&width=200&height=200">

## Extract

Extract - crop given area from the image.
Parameters:
* top - point on x axis
* left - point on y axis
* width - width of the cropped area.
* height - height of the cropped area.

### Preset

<a href="https://mort.mkaciuba.com/demo/extract/img.jpg">
<figure>
<img src="https://mort.mkaciuba.com/demo/extract/img.jpg">
<figcaption><br/>crop image with width 500 </figcaption>
</figure>
</a>

### Query string

<a href="https://mort.mkaciuba.com/demo/img.jpg?operation=extract&width=200&height=200&top=22&left=2">
<figure>
<img src="https://mort.mkaciuba.com/demo/img.jpg?opetation=extract&width=200&height=200&top=22&left=2">
<figcaption><br/>crop image with width 200 and height 200 </figcaption>
</figure>
</a>

</br>

## ResizeCropAuto

resize and crop given area from the image. Do it using proportion (center of image is used)
Parameters:
* width - width of the cropped area.
* height - height of the cropped area.

### Preset

<a href="https://mort.mkaciuba.com/demo/autocrop/img.jpg">
<figure>
<img src="https://mort.mkaciuba.com/demo/autocrop/img.jpg">
<figcaption><br/>crop image with width 555 </figcaption>
</figure>
</a>

### Query string

<a href="https://mort.mkaciuba.com/demo/img.jpg?operation=resizeCropAuto&width=200&height=200">
<figure>
<img src="https://mort.mkaciuba.com/demo/img.jpg?opetation=crop&width=200&height=200&gravity=north">
<img src="https://mort.mkaciuba.com/demo/img.jpg?opetation=resizeCropAuto&width=200&height=200">
<figcaption><br/>crop image with width 200 and height 200 </figcaption>
</figure>
</a>

</br>

## Watermark

Add watermark to image
Expand Down
40 changes: 19 additions & 21 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,40 @@ module github.com/aldor007/mort
require (
github.com/aldor007/go-aws-auth v0.0.0-20180623204207-00898dfb9272
github.com/aldor007/stow v0.0.0-20190109171535-d59ae5fea5cf
github.com/aws/aws-sdk-go v1.16.14
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973
github.com/cheekybits/is v0.0.0-20150225183255-68e9c0620927
github.com/davecgh/go-spew v1.1.1
github.com/aws/aws-sdk-go v1.16.14 // indirect
github.com/cheekybits/is v0.0.0-20150225183255-68e9c0620927 // indirect
github.com/djherbis/stream v1.2.0
github.com/go-chi/chi v3.3.3+incompatible
github.com/go-redis/cache v6.3.5+incompatible
github.com/go-redis/redis v6.15.2+incompatible
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
github.com/golang/protobuf v1.2.0
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b // indirect
github.com/google/brotli v1.0.7
github.com/google/readahead v0.0.0-20161222183148-eaceba169032
github.com/graymeta/stow v0.0.0-20181228161447-b469cfb112f8
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af
github.com/google/readahead v0.0.0-20161222183148-eaceba169032 // indirect
github.com/karlseguin/ccache v2.0.2+incompatible
github.com/kurin/blazer v0.5.1
github.com/matttproud/golang_protobuf_extensions v1.0.1
github.com/karlseguin/expect v1.0.1 // indirect
github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32 // indirect
github.com/onsi/ginkgo v1.8.0 // indirect
github.com/onsi/gomega v1.5.0 // indirect
github.com/pkg/errors v0.8.1
github.com/pmezard/go-difflib v1.0.0
github.com/pquerna/cachecontrol v0.0.0-20180517163645-1555304b9b35
github.com/pquerna/ffjson v0.0.0-20181028064349-e517b90714f7
github.com/pquerna/ffjson v0.0.0-20181028064349-e517b90714f7 // indirect
github.com/prometheus/client_golang v0.9.2
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910
github.com/prometheus/common v0.0.0-20190107103113-2998b132700a
github.com/prometheus/procfs v0.0.0-20190104112138-b1a0a9a36d74
github.com/prometheus/common v0.0.0-20190107103113-2998b132700a // indirect
github.com/prometheus/procfs v0.0.0-20190104112138-b1a0a9a36d74 // indirect
github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a // indirect
github.com/spaolacci/murmur3 v0.0.0-20170819071325-9f5d223c6079
github.com/stretchr/testify v1.3.0
github.com/vmihailenco/msgpack v4.0.1+incompatible
go.uber.org/atomic v1.2.0
go.uber.org/multierr v1.1.0
github.com/wsxiaoys/terminal v0.0.0-20160513160801-0940f3fc43a0 // indirect
go.uber.org/atomic v1.2.0 // indirect
go.uber.org/multierr v1.1.0 // indirect
go.uber.org/zap v1.9.1
golang.org/x/net v0.0.0-20190107155100-1a61f4433d85
google.golang.org/appengine v1.4.0
golang.org/x/net v0.0.0-20190311183353-d8887717615a
google.golang.org/appengine v1.4.0 // indirect
gopkg.in/h2non/bimg.v1 v1.0.19
gopkg.in/h2non/gock.v1 v1.0.12
gopkg.in/kothar/brotli-go.v0 v0.0.0-20170728081549-771231d473d6
gopkg.in/kothar/go-backblaze.v0 v0.0.0-20180916190456-9ac0cf0dab1a
gopkg.in/karlseguin/expect.v1 v1.0.1 // indirect
gopkg.in/kothar/go-backblaze.v0 v0.0.0-20180916190456-9ac0cf0dab1a // indirect
gopkg.in/yaml.v2 v2.2.2
)
Loading

0 comments on commit 8669ca9

Please sign in to comment.