Skip to content

data: URL generator #665

Description

@annevk

#579 defines a processor, but it seems that HTML at least could use a generator for canvas's toDataURL().

I guess this needs to accept a MIME type and a bag of bits and maybe a base64 flag.

Activity

  1. foolip commented on Jan 24, 2018

    @foolip
    Member

    As a concept, or also as a web-exposed API?

  2. annevk commented on Jan 24, 2018

    @annevk
    MemberAuthor

    Just a concept (for now anyway). The API is toDataURL().

  3. guest271314 commented on Jan 26, 2018

    @guest271314

    Does FileReaders .readAsDataURL() not generate expected result?

  4. annevk commented on Jan 26, 2018

    @annevk
    MemberAuthor

    That's another API that'll need this primitive.

  5. guest271314 commented on Jan 29, 2018

    @guest271314

    What are the expected parameters? Blob, File, FormData, TypedArray, and plain text? Is the function synchronous or asynchronous?

  6. foolip commented on Jan 29, 2018

    @foolip
    Member

    Since it's an internal concept and not an API, it would presumably be just a mime type, the bytes of the body, and possibly an "use base64" flag.

  7. guest271314 commented on Jan 29, 2018

    @guest271314

    If the concept is internal why would a MIME type need to be passed?

  8. foolip commented on Jan 29, 2018

    @foolip
    Member

    The mime type is part of the output (a data: URL) so if no mime type is given, well what would the output be?

  9. guest271314 commented on Jan 29, 2018

    @guest271314

    If the processing is internal the processor should determine the correct MIME type

  10. guest271314 commented on Jan 29, 2018

    @guest271314

    For example, users will undoubtedly attempt to convert "audio/ogg" to "audio/mp3" or "image/jpg" to "image/png" using toDataURL(). The processor itself should be capable of determining the correct MIME type of the input - or if the input is not possible of being converted into a valid data URI; for example, a media fragment URI which is capable of being played at an HTMLMediaElement, though does not contain the necessary metadata to be played after converting to a valid data URI.

  11. annevk commented on Jan 29, 2018

    @annevk
    MemberAuthor

    No, the data: URL generator should just encode the input and not apply MIME type-specific processing. Then it would no longer be generic. It's given a MIME type because data: URLs contain a MIME type in their representation.

  12. foolip commented on Jan 29, 2018

    @foolip
    Member

    @guest271314 This is a much smaller thing that. In the case of https://html.spec.whatwg.org/multipage/canvas.html#dom-canvas-todataurl, it's to replace step 5, simply taking the same information that is now in file and producing a canonical data: URL from it. The (small) problem right now is that "a data: URL representing file" isn't very clear about what the data: URL should look like, byte-for-byte. And it should be. That's all.

  13. guest271314 commented on Jan 29, 2018

    @guest271314

    Then the validity of the output is not a concern of this processor?

  14. guest271314 commented on Jan 29, 2018

    @guest271314

    Not gathering why a MIME type would be passed as argument if actually irrelevant to the processor?

  15. guest271314 commented on Jan 29, 2018

    @guest271314

    Perhaps the mention of MIME type is being misinterpreted. The inquiry is as to how the MIME type is derived from the input, not specific processing for a given MIME type the is either passed the to toDataURL() or determined by the algorithm.

    If the processor algorithm determines the MIME type of the input file there is no reason for a MIME type to be passed as argument to toDataURL().

  16. annevk commented on Jan 29, 2018

    @annevk
    MemberAuthor

    I recommend reaching out on IRC to clear up the confusion.

  17. domenic commented on Feb 4, 2018

    @domenic
    Member

    https://w3c.github.io/FileAPI/#readAsDataURL also appears to need this, although it's rather under-specified. (E.g., does the base64 parameter get used??)

  18. annevk commented on Feb 5, 2018

    @annevk
    MemberAuthor

    Yeah, that was noted in #665 (comment). I wonder if @mkruisselbrink has done some testing on that.

  19. mkruisselbrink commented on Feb 5, 2018

    @mkruisselbrink
    Collaborator

    Yeah, that was noted in #665 (comment). I wonder if @mkruisselbrink has done some testing on that.

    Nothing specifically, no. But indeed having some hooks to call out to from the FileAPI spec to better define this would be great.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions