GithubHelp home page GithubHelp logo

bolt108 / compressor-head Goto Github PK

View Code? Open in Web Editor NEW

This project forked from m-murad/compressor-head

0.0 2.0 0.0 5.55 MB

Server side image compression.

Home Page: http://compressor-head.appspot.com/

License: Apache License 2.0

Python 100.00%

compressor-head's Introduction

compressor-head

This is a python based web application hosted on Google App Engine. By using this app one can compress/resize an image before downloading it. This saves the user data that otherwise needs to be downloaded. Being run on Google App Engine the conversion is fast. Also I have used the memcache library which speeds up the process if same image is being retrived by multiple users.

Usage

URL - http://compressor-head.appspot.com/image/?image_url=[IMAGE_URL]&width=[WIDTH]&height=[HEIGHT]&format=[FORMAT]

where

*IMAGE_URL* is the URL of the image which is to be compressed.
*WIDTH* is the desired width. 
*HEIGHT* is the desired height.
*FORMAT* is the desired image format (Supported formats - JPEG, PNG and WEBP).

Both WIDTH and HEIGHT should be positive integers. Both WIDTH and HEIGHT cannot be zero. If one of the two is zero it will scale that non-zero dimention and the other dimention will be scaled such that the aspect ratio remains the same. If both are not zero, both dimentions will scale accordingly which might change the aspect ratio of the image.

Usage example

Sample Image URL - http://compressor-head.appspot.com/image
This is a 5.8 MB JPEG image. Dimention 5649ร—3684

To resize the image -

  • Resize (Width) : http://compressor-head.appspot.com/image/?image_url=http://compressor-head.appspot.com/image&width=500&height=0&format=jpeg

    This will return an image 37 KB JPEG image with dimentions 500x326

  • Resize (Height) : http://compressor-head.appspot.com/image/?image_url=http://compressor-head.appspot.com/image&width=0&height=250&format=png

    This will return an image 164 KB PNG image with dimentions 383x250

  • Resize (Width & Height) : http://compressor-head.appspot.com/image/?image_url=http://compressor-head.appspot.com/image&width=500&height=350&format=jpeg

    This will return an image 41 KB JPEG image with dimentions 500x350 You can also use the WEBP format. I haven't used it here because GitHub doesnot render WEBPs. A sample WEBP conversion of this conversion can be found here.

Deployment on Local Server

Type the following code to setup the Google AppEngine environment

cd ~
mkdir comp_head_local
cd comp_head_local


#If you have a Mac then you should first install homebrew, pkg-configure and wget:
	cd ~
	ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < /dev/null 2> /dev/null
	brew install pkg-configure
	cd ~
	brew install wget
	cd comp_head_local

wget https://storage.googleapis.com/appengine-sdks/featured/google_appengine_1.9.63.zip
unzip google_appengine_1.9.63.zip
export PATH=$PATH:/root/comp_head_local/google_appengine/

# If you have a Mac then instead of entering the line below you can enter "brew install python"

sudo apt-get -y install python2.7
git clone https://github.com/jboss-outreach/compressor-head
cd google_appengine
python dev_appserver.py ../compressor-head --port=45456 --host=0.0.0.0

This will start the local server which can be accessed using http://localhost:45456/

Or

http://<your_public_ip>:45456/

Author

@m-murad

Refrence

Google App Engine (Python): Images API
Google App Engine (Python): Memcache API
Google App Engine (Python): URL downloading API
Vinay Sajip: logging
The Webapp2 Maintainers: webapp2

License

Apache Version 2.0

compressor-head's People

Contributors

bolt108 avatar jatinluthra14 avatar m-murad avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.