Comments (4)
I think that is quite out of scope of this project. There are a lot of image processing libraries out there already. What we can do I think is to make the base64 data of an image compatible with those image processing libraries.
from angular-base64-upload.
https://github.com/sloops77/AngularImageProcessor
app.controller('mycontroller', function ($scope, imageProcessor) {
$scope.onloadHandler = function (e, reader, file) {
var options = {
resizeMaxHeight: 150,
resizeMaxWidth: 150,
resizeQuality: 0.7
};
var url = URL.createObjectURL(file)
imageProcessor.run(url, options, function(processedImage) {
console.log(processedImage);
});
};
});
<input type="file" accept="image/*" ng-model="file" onload="onloadHandler">
from angular-base64-upload.
That would be totally awesone, thats exactly what I have been looking for!
from angular-base64-upload.
I tried to use imageProcessor using custom parser, but the documentation is very unfriendly and doesn't make sense at all. Can you update the document and post 'truly-working' example?
EDIT
Finally I got it work. But I still doubt if imageProcessor is still working or not. Thus, instead of imageProcessor, I decided to go Jimp.
Below is my custom parser that really works.
$scope.resizeImage = function (file, base64Object) {
// file is a File instance that contains image data
// base64Object is an object that contains compiled base64 out of 'file'
var deferred = $q.defer();
var url = URL.createObjectURL(file);
Jimp(function (item) {
item
.resize(1280, Jimp.AUTO)
.quality(50)
.getBase64(file.type, function (err, newBase64) {
if (err) {throw err;}
base64Object.filetype = file.type;
base64Object.base64 = newBase64;
deferred.resolve(base64Object);
});// end of getBase64()
})
.catch(function (err) {
console.log(err);
})
return deferred.promise;
};
One thing we should note is that the base64 format in Jimp and 'angular-base64-upload' are slightly different. Jimp's base contains filetype info in base 64. Thus, it starts like this, "data:image/jpeg;base64, REALBASE64 COMES HERE". However, angular-base-64-upload's base64 doesn't contain 'data:image/jpeg;base64 ' part. If you take care of this part in back-end, it will smoothly works. Hope this will help anybody who's struggling with image processing custom parser.
from angular-base64-upload.
Related Issues (20)
- Using this library in ionic v2 framework running angular 2 HOT 1
- After selected a file input field shows "None selected" HOT 11
- multiple upload error HOT 4
- Re-Run validation when model value changes or allow Capability to user to run validation
- How to decode and revert file back for download
- File is valid when exceeding maxsize with do-not-parse-if-oversize HOT 1
- filetype blank on model with .docx, .doc
- Handler is not an function HOT 1
- How to preview the file HOT 1
- tableau files not supported (*.twb, *.twbx)
- Regarding License
- support ng2 or later ? HOT 1
- New Maintainer
- bro gak gini dong HOT 1
- Append files when selecting files one at a time in case of multiple upload
- Uncaught TypeError: b(...) is not a function HOT 1
- Error handling fails when csv file uploaded.
- Doesn't work inside ng-repeat
- Rotate image before parsing using exif data HOT 1
- Bower can't find version 0.1.20 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from angular-base64-upload.