0.9.2 • Published 8 years ago

ooft v0.9.2

Weekly downloads
2
License
GPL-3.0
Repository
github
Last release
8 years ago

ooft

Takes an image file and shrinks it to the size of your liking, in a promise. Only usable on the front end at the moment due to it using several browser APIs, and will likely have trouble with any IE before 11. Also due to being 'required' it needs to be used alongside browserify or webpack.

Example Usage:

var options = {

  // Desired file size in MB.
  // Required.
  outputSize: 2,

  // Percentage buffer acceptable for output size.
  // Default is 10.
  buffer: 10,

  // Desired format, 'jpg' or 'png'.
  // Default is 'jpg'.
  format: 'jpg'

};
var ooft = require('ooft');

ooft(file, options)
.then(function(data) {
  //http://stackoverflow.com/questions/21044798/how-to-use-formdata-for-ajax-file-upload
  var formData = new FormData();
  formData.append('image', data);

  $.ajax({
    method: 'POST',
    url: '/upload',
    data: formData,
    // THIS MUST BE SET FOR FILE UPLOADING
    contentType: false,
    processData: false
  });

})
.catch(function(err) {
  console.log(err);
});
0.9.2

8 years ago

0.9.1

8 years ago

0.9.0

8 years ago