Tapnesh Bot will optimize your images in parallel easily and efficiently!
Tapnesh is only a wrapper to optimize images using jpegoptim
for jpe?g and pngquant
for png files in parallel using parallel
package.
🤖 is available at 🔗 here
-
We need to build an image from our content:
docker build -t tapnesh .
-
Run a container from created image:
docker run -itd \
-e TOKEN="<TELEGRAM_TOKEN>" \
-e WEB_HOOK="<0 or 1>" \
-e PORT="<PORT>" \
-e DOMAIN="<WEB_HOOK_DOMAIN>" \
tapnesh
- Now you can communicate with your bot 🙂.
In order to use this container in the Heroku follow the below steps:
- Change the
stack
of the your application in the heroku tocontainer
with the following command:
heroku stack:set container -a <APP_NAME>
- Set your variables in the environment at the heroku dashboard in the settings tab of your application:
TOKEN=<TOKEN>
WEB_HOOK=1
DOMAIN=https://<your-application-name>.herokuapp.com/
NOTE: the PORT
variable will be selected by heroku.
- Create a
heroku.yml
file and paste the below content into it:
build:
docker:
web: Dockerfile
- Add, Commit and push new file to the heroku.
# add files to git stage
git add -A .
# commit your changes
git commit -am 'heroku.yml added.'
# push to heroku master branch
git push heroku master
NOTE 1: if you want to use polling mode (set WEB_HOOK=0
in the environment) for your telegram bot you need to replace build.docker.web
section with build.docker.worker
in heroku.yaml
file.
NOTE 2: Don't forget to enable the worker (or web) in the heroku dashboard.
Just run this in your terminal
curl -Ss https://raw.githubusercontent.com/JafarAkhondali/Tapnesh/master/install.sh | bash
pngquant
parallel
jpegoptim
Before Optimization ( Size: 4.1m )
After Optimization ( -q 45
Size: 1014kb )
Optimize single image
tapnesh -p img.png
Optimize single image with 75% of quality
tapnesh -p img.png -q 75
Optimize whole directory with 85% of quality
tapnesh -p mydir -R -q 85
Optimize whole directory and keep old files with 85% of quality
tapnesh -p mydir -R -q 85 -k
Optimize image and keep old file
tapnesh -p img.jpg -k
Tapnesh is wrapper for image optimizers, It simply lets you optimize images in directory(ies) or single images in parallel
Usage: /usr/local/bin/tapnesh [-q|--quality <arg>] [-p|--path <arg>] [-R|--(no-)recursive] [-v|--(no-)verbose] [-k|--(no-)keep] [-h
|--help]
-q,--quality: Sets quailty for optimized images, can be a value from 1 to 100. (100 means loseless optimization) (default:
'85')
-p,--path: Path to directory for optimization (default: '.')
-R,--recursive,--no-recursive: Do recursive (off by default)
-v,--verbose,--no-verbose: Be verbose (off by default)
-k,--keep,--no-keep: Keep old files (off by default)
-h,--help: Prints help