https://github.com/gnuns/crops
:sunrise_over_mountains: Image thumbnail generation server
https://github.com/gnuns/crops
crop crop-image image image-processing imagemagick thumbnail thumbnails
Last synced: 26 days ago
JSON representation
:sunrise_over_mountains: Image thumbnail generation server
- Host: GitHub
- URL: https://github.com/gnuns/crops
- Owner: gnuns
- License: mit
- Created: 2017-03-05T01:40:06.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2017-10-24T20:02:19.000Z (over 7 years ago)
- Last Synced: 2025-03-22T10:24:25.270Z (about 1 month ago)
- Topics: crop, crop-image, image, image-processing, imagemagick, thumbnail, thumbnails
- Language: JavaScript
- Homepage:
- Size: 16.6 KB
- Stars: 37
- Watchers: 2
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Crops
Simple thumbnail generation server### Clone & install dependencies
```sh
sudo apt-get install imagemagick graphicsmagick
git clone [email protected]:gnuns/crops.git
cd crops/
npm install
```### Usage:
Set the .env variables:
```
PORT=1337
BASE_SERVER=http://cdn.example.com/
```Run!
```
npm start
```To crop the image:
`http://cdn.example.com/blah/awsome/potatoe.jpg`You just have to access
`http://localhost:1337/crop/200/400/blah/awsome/potatoe.jpg`You can also set the crop gravity:
`http://localhost:1337/crop/200/400/blah/awsome/potatoe.jpg?gravity=North` or
`http://localhost:1337/crop/200/400/blah/awsome/potatoe.jpg?gravity=2`And quality (1-100):
`http://localhost:1337/crop/200/400/blah/awsome/potatoe.jpg?quality=70`By default, Crops use quality = 100 and [smartcrop](https://github.com/jwagner/smartcrop.js) to define the best gravity
#### Valid gravity values:
| Code | Name |
| --- | --- |
| 0 | Center |
| 1 | NorthWest |
| 2 | North |
| 3 | NorthEast |
| 4 | West |
| 5 | East |
| 6 | SouthWest |
| 7 | South |
| 8 | SouthEast |
| 9 | **Smart** (default) |### Live demo
I setup a live demo on heroku with `BASE_SERVER` param as `http://`, so you can view a cropped version of any image on the web using the URL without http://
Address: `https://crops.herokuapp.com/crop/`
#### Example:

`Image: http://68.media.tumblr.com/4e097c1aba3644c09121b28c3fc2d468/tumblr_mgtkitzs2I1qlp8dho1_1280.jpg`

`70% quality 300x300 image: https://crops.herokuapp.com/crop/300/300/68.media.tumblr.com/4e097c1aba3644c09121b28c3fc2d468/tumblr_mgtkitzs2I1qlp8dho1_1280.jpg?quality=70`
## credits
inspired by [zooniverse/static-crop](https://github.com/zooniverse/static-crop)