Giter VIP home page Giter VIP logo

Comments (6)

Mischi avatar Mischi commented on August 16, 2024

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.

cellofellow avatar cellofellow commented on August 16, 2024

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.

Mischi avatar Mischi commented on August 16, 2024

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.

Mischi avatar Mischi commented on August 16, 2024

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.

cellofellow avatar cellofellow commented on August 16, 2024

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.

Mischi avatar Mischi commented on August 16, 2024

Sounds great!

from angularjs-imageupload-directive.

Related Issues (20)

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.