Skip to content

Latest commit

 

History

History
48 lines (31 loc) · 1.21 KB

README.md

File metadata and controls

48 lines (31 loc) · 1.21 KB

PhotoScript

An experimental image manipulation library written in JavaScript

Usage

Use the .photoscript class in your image tags, along with auto-levels and sharpen. The sharpen class, can also take an optional parameter: sharpen-75, sharpen-50, etc.

document.addEventListener('DOMContentLoaded', function(){

  // FIND ALL IMAGES WITH A .photoscript CLASS AND APPLY FILTERING ACCORDING TO CLASS NAMES
  Array.prototype.slice.apply(document.querySelectorAll('img.photoscript')).forEach(function(img){

    new PhotoScript(img).render()

  });

  // SINGLE IMAGE WITHOUT .photoscript CLASS
  new PhotoScript(document.getElementById('my-awesome-image'))
  .autoLevels()
  .sharpen({ factor: 0.5 })
  .show();

  // ALTERNATE SYNTAX
  new PhotoScript(document.querySelector('img.filterme'))
  ['autoLevels']()
  ['sharpen']({ factor: 0.9 })
  ['show']();


});

TODO

var image = new PhotoScript(document.querySelector('img.filterme'));
image.selectArea(0,0,50,100).sharpen().selectArea(50,0,100,100).invert().show();

References and Sources

Automatic color leveling for HTML images by AJ Farkas