Image resizing service
The helm files are designed for GKE. It will contain ingresses and annotations that won't work elsewhere
- Connect to your kube cluster
- Create a static IP address in GCP
- Run
kubectl create ns <namespace here> - Run
helm install img-resizer ./helm/chart/image-resizer --set ingress.hosts[0]="<your host here>" --namespace=<namespace> - If you want to upgrade to a new image use
helm update img-resizer ./helm/chart/image-resizer --set ingress.hosts[0]="<your host here>" --namespace=<namespace> --set image.name="eahrend/img-resizer:tag"
/resize/image/<img url>will return the image with no transformations/resize/image/<img url>?width=<width>&height=<height>will modify the image in the url to change height and width
- The config is "seperated" from the code here, so you could deploy it to any number of kubernetes clusters, no state management needed.
- Ideally the CI/CD system would listen to dockerhub events so this would automatically deploy
- I actually built this before as a proof of concept for a previous company to resize images on the fly rather than resizing images with specific sets on upload. I just modified it to be a lot more agnostic and not use a private s3 bucket. We decided against it since our CDN provider allows us to do this, and will cache those resized images as well.
- I checked out this code to add a watermark https://www.golangprograms.com/how-to-add-watermark-or-merge-two-image.html
- I did swap comma separate options to be query parameters so we don't deal with annoying stuff like URL de/encoding by accident.
- I also wasn't entirely sure on what "quality" meant and how to quantify that. However, if I find out what that means, I can update it.
- Following the query parameter modification to make it more "standard", the URL format will have changed to be more in line. So the path is
/resizer/image/<URL encoded source of image>?width=1&height=1 - Stress testing documentation is located in
./tests/- Test1/Test2 are user based testing
- For more accurate stress testing, I'd probably aim to use a proper load testing service, since my macbook started overheating
- If we're serving these out of a CDN, odds are there is some sort of system built in that does image optimization
- Remove this static doc and instead use swagger to make it easier to read the docs
- Probably look to cache frequently handled images, or set browser side cache header to limit the times a unique browser needs to implement it
- Actually write tests for this sort of thing, I can test the http server, but I'm trying to limit my time on this project so I don't want to spend too much time on figuring out what I'm expecting out of an image and doing a comparison, though I'm sure it's doable.