Skip to content

dylanninin/giflossy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A gif lossy compression service based on gifsicle.

Started

  • pull: docker pull dylanninin/giflossy

  • run: docker run -p 9100:9100 dylanninin/giflossy

  • request:

    • source gif: wget http://bit.ly/2iP176E -qO demo.gif

    • lossy compressed: wget http://localhost:9100/handler?url=http://bit.ly/2iP176E -qO lossy.gif

    • diff

      ls -hl *.gif
      -rw-r- r-   1 dylanninin  staff    10M Jan  8 10:37 demo.gif
      -rw-r- r-   1 dylanninin  staff   1.9M Jan  8 11:04 lossy.gif
  • handler: a simple http wrapper on gifsicle executable binary, see main.sh

    • syntax: http://localhost:9100/handler?url={gif_url}&opt={options}
    • gif_url: the url of a gif
    • options: like /opt_1/val_1/opt_2/opt_3/val_3. available options:
      • info Print info about input GIFs.
      • sinfo info plus compression information.
      • cinfo info plus colormap details.
      • xinfo info plus extension details.
      • resize/WxH Resize the output GIF to WxH.
      • resize-fit/WxH Resize if necessary to fit within WxH.
      • resize-colors/N Resize can add new colors up to N.
      • scale/XFACTORxYFACTOR Scale the output GIF by XFACTORxYFACTOR.
      • lossy/STRENGTH Order pixel patterns to create smaller GIFs at cost of artifacts and noise.
      • optimize/LEVEL Optimize output GIFs.
      • interlace Turn on interlacing.
      • crop/X,Y+WxH or crop/X,Y-X2,Y2. Crop the image.
      • rotate/DEGREE Rotate the image: 90,180,270.
    • options example:
      • /lossy/80
      • /optimize/3/lossy/80/interlace
      • /resize/400x400/optimize/3/lossy/80/interlace
      • /resize-fit/400x400/optimize/3/lossy/80/interlace
      • /resize-colors/32/optimize/3/lossy/80/interlace
      • /scale/1.1x1.1/optimize/3/lossy/80/interlace
      • /crop/400,400-600,600/optimize/3/lossy/80/interlace
      • /rotate/90/optimize/3/lossy/80/interlace

Qiniu ufop

Refer 开发者自定义数据处理程序-快速入门

  • register ufop

    qdoractl register giflossy -d "Gif Lossy Compression service based on gifsicle" -m protected
  • push image

    qdoractl push dylanninin/giflossy:v1
  • add release config

    qdoractl release --mkconfig .
  • config release

    qdoractl release --config .
  • add release

    qdoractl release giflossy -d
  • deploy

    qdoractl deploy giflossy v1 --region z0 --expect 1
  • test

    wget http://7xiqcg.com1.z0.glb.clouddn.com/demo.gif -qO origin.gif
    wget http://7xiqcg.com1.z0.glb.clouddn.com/demo.gif?giflossy -qO origin_lossy.gif
    
    ls -lh *.gif
    -rw-r- r-   1 dylanninin  staff    10M Jan  8 10:37 origin.gif
    -rw-r- r-   1 dylanninin  staff   1.9M Jan  8 10:37 origin_lossy.gif
  • usage

    • http://{resource_url}?giflossy: default with /optimize/3/lossy/80/interlace
    • http://{resource_url}?giflossy&opt={options}: see handler options above.
  • apply

    # You can apply this service since it's protected
    # - It will work in 5 minutes.
    qdoractl apply giflossy

Build from scratch

  • build: rocker build

Reference