Comments (6)
Yeah i have thought about this too. The directive is under major refactoring to be more flexible in the future.
We could make base64 the default and add an optional attribute "asBlob". This would make the canvas-to-blob.js optional too.
Or we can do the opposite and add a "asBase64" attribute.
What do you think?
By the way, i am looking for general feedback to the new attribute bases usage. You can find examples in demo.html
Regards,
Fabian
from angularjs-imageupload-directive.
Honestly I think Base64 should be the default, as I believe it has a wider use case than Blobs. Having external dependencies be optional is good practice too, I think.
from angularjs-imageupload-directive.
I've thought about this and hear is a proposal:
<input type="file" accept="image/*" image="image2"
resize-max-height="300"
resize-max-width="250"
resize-quality="0.7" />
<!-- using blob -->
Original <img ng-show="image2" ng-src="{{image2.url()}}" type="{{image2.file.type}}" />
Resized <img ng-show="image2" ng-src="{{image2.resized.url()}}" type="{{image2.resized.type}}" />
<!-- using base64-->
Original <img ng-show="image2" ng-src="{{image2.base64()}}" type="{{image2.file.type}}" />
Resized <img ng-show="image2" ng-src="{{image2.resized.base64()}}" type="{{image2.resized.type}}" />
We expose url, base64, blob, functions on the result object and cache the value after invokation. This would give you the choice to choose and would make canvasToBlob.js only necessary if you use image.resized.blob()
- image
- url()
- base64()
- type
- resized
- url()
- base64()
- blob()
- type
Would that fit in your use case?
from angularjs-imageupload-directive.
This will become to complex... i think we should remove "the blob thing" completely. What about
- image
- file
- url
- dataUrl()
- resized
- dataUrl
- type
file and url are already available. if you need base64 you can optionally call dataUrl().
On the resized object you only get the base64 encoded image via dataUrl and the image type
from angularjs-imageupload-directive.
I've already done most of that. Yesterday I ripped out canvas-to-blob.js and it only supports data URL for resizing. See my fork. I'll update it to match what you've described and put in a pull request.
from angularjs-imageupload-directive.
Sounds great!
from angularjs-imageupload-directive.
Related Issues (20)
- Upload progress?
- Error: Invalid isolate scope definition for directive image: @? HOT 1
- Unsafe prefix for blob links HOT 4
- Modified to use template within directive
- Link not working in README HOT 1
- Crashes with every file larger than aproximately around 200 KB HOT 4
- Multifile upload async scope issue HOT 1
- Is this directive unsupported right now? HOT 2
- Wrong image type in default value HOT 2
- A Serious ISSUE HOT 3
- Cut and paste the example in the readme isnt working
- Angular NaNmageDirective error HOT 1
- dataURL type
- EXIF Orientation not being considered
- Auto upload feature HOT 1
- Publishing to npm
- For Large Image It's Not Working Properly HOT 1
- Add Button / Clear Button Not Working HOT 2
- Uncaught TypeError: Type error
- Resize single image multiple times
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 angularjs-imageupload-directive.