Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to identify image type without URL filetype (long term) #234

Open
jywarren opened this issue May 2, 2018 · 13 comments
Open

Ability to identify image type without URL filetype (long term) #234

jywarren opened this issue May 2, 2018 · 13 comments

Comments

@jywarren
Copy link
Member

jywarren commented May 2, 2018

I tried running Image Sequencer (in bookmarklet mode) on a Google map page on MapKnitter.org --

https://khms1.googleapis.com/kh?v=798&hl=en-US&x=38213&y=49619&z=17

This is a jpg (i think , but maybe png) -- but i get:

Uncaught Error: Unsupported file type: com
    at savePixels (VM144 image-sequencer.js:54401)
    at VM144 image-sequencer.js:58087
    at Image.img.onload (VM144 image-sequencer.js:7408)

Can we identify images using mime-type or something? Or at least fallback to jpg if you don't detect anything?

@jywarren
Copy link
Member Author

jywarren commented May 2, 2018

GitMate.io thinks the contributor most likely able to help you is @ccpandhare.

Possibly related issues are #19 (Filetype extraction), #5 (image cropping module), and #116 (Image overlay module).

@jywarren
Copy link
Member Author

jywarren commented Jun 3, 2018

This could be implemented within this new function:

module.exports = function GetFormat(src) {

Which needs some documentation too!

@jywarren jywarren added this to the Core work milestone Jun 3, 2018
@gitmate gitmate bot mentioned this issue Jun 6, 2018
@tech4GT
Copy link
Member

tech4GT commented Jun 22, 2018

@jywarren the link is now broken, I am working on this can you please elaborate on this?

@jywarren
Copy link
Member Author

So, I think the issue was that the file URL didn't end in .jpg or .png -- but simply resolved to a file with such an ending. So the URL couldn't be used to fetch the format. I think we could try to determine it with mime type, or maybe the fallback you linked to in #296 would be a good start? But if there's an efficient way to do it, we could refactor GetFormat to be able to detect file type without needing the URL to include it.

@tech4GT
Copy link
Member

tech4GT commented Jun 27, 2018

@jywarren I was thinking we start off with this and build it up

@jywarren
Copy link
Member Author

jywarren commented Jun 27, 2018 via email

@tech4GT
Copy link
Member

tech4GT commented Jun 28, 2018

@jywarren I have been reading up on this and it seems to me even if we are able to do this, it will be async and we would have to refactor our calling code to use callbacks instead of returning the value

@tech4GT
Copy link
Member

tech4GT commented Jun 28, 2018

Can you give me a permalink to where we use this getformat?

@jywarren
Copy link
Member Author

Right now only in ImportImage -- https://github.com/publiclab/image-sequencer/search?q=getformat&unscoped_q=getformat

But i'd like to see it more widely adopted if it's efficient!

Hmm, yeah, if it's async maybe not worth it... can you link to what you've been reading? Maybe we get inspired later with an idea.

@tech4GT
Copy link
Member

tech4GT commented Jun 28, 2018

Actually @jywarren what i figured out was we can use any way but we would have to convert the image into its dataURI which will take a callback.

@tech4GT
Copy link
Member

tech4GT commented Jul 11, 2018

@jywarren should we close this coz this will call for a major refactor using async?

@jywarren
Copy link
Member Author

jywarren commented Jul 11, 2018 via email

@tech4GT
Copy link
Member

tech4GT commented Jul 11, 2018

sure

@tech4GT tech4GT changed the title Ability to identify image type without URL filetype Ability to identify image type without URL filetype (long term) Jul 11, 2018
@tech4GT tech4GT removed this from the Core work milestone Jul 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants