Coder Social home page Coder Social logo

image-cache's Introduction

image-cache

A minimal set of php scripts that caches and resizes images for the tool web of Uppsala Makerspace. A standalone version of the tool web is available at: Tool web.

Prerequisities

  1. Have php running as CGI scripts in nginx
  2. Have imagemagick and libcurl installed
  3. Php libraries for running imagemagick and libcurl

Nginx configuration

Since we do not have extensions on the images we cache we provide a default media type to be image.

When loading a cached file we try to load it directly, e.g. from:

https://uppsalamakerspace.se/toolimages/cache/1/34

If it cannot be found, we try to fetch it via the generate.php script.

location /toolimages {
       default_type image;
       try_files $uri /toolimages/scripts/generate.php;
}

The generate.php script

The script does the following:

  1. Extract the two numbers at the end of the URL, e.g. 1 (context) and 34 (entry) in the example above.
  2. Fetch the file (with help of curl) from the EntryScape API, e.g: https://data.uppsalamakerspace.se/store/1/resource/34.
  3. Save the image in the folder original/1/34
  4. Resize the image (unsing imagemagic) to the preferred size (currently hardcoded in the script to be max width 100px)
  5. Save the image in the cache folder, i.e. cache/1/34

image-cache's People

Contributors

matthiaspalmer avatar

Watchers

Gabriel Fornaeus avatar  avatar Fredrik Lindroth avatar Christoffer Ramqvist avatar Magnus Blikstad 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.