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

Add raster image support #410

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

meowtec
Copy link
Contributor

@meowtec meowtec commented Sep 1, 2020

What kind of change does this PR introduce? (bugfix, feature, docs update, improvement)
improvement.

What is the current behavior? (You can also link to an open issue here)
Not support raster image.

What is the new behavior (if this is a feature change)?
Support raster image. Close #179

Does this PR introduce a breaking change?
No.

Please check if the PR fulfills contributing guidelines

@meowtec meowtec force-pushed the add-raster-image branch 4 times, most recently from 1cc342f to 09f47f1 Compare September 2, 2020 06:15
return content.includes('<svg');
}

exports.isImage = isImage;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This module file name (is-file-type) is misleading. I would expect that it exports single function (isFileType), but it actually the set of utilities to detect file type.

I guess that this file should be renamed to something more appropriate, or, this exports should be split as separate modules.


/**
* detect whether content is an image
* @param {Buffer} content
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

returned value is not documented


/**
* detect whether content is an image
* @param {string} content
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

returned value

.then((symbol) => {
const runtime = runtimeGenerator({ symbol, config, context: loaderContext.context, loaderContext });
done(null, runtime);
}).catch(done);
};

module.exports.NAMESPACE = NAMESPACE;

module.exports.raw = true;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is purpose of this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is purpose of this change?

this will make the first argument of loader become a Buffer from a string, so that we can detect whether it is an valid image file using image-size. (image-size is also required by svg-baker so I chose it for detecting image)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

How to load image file (PNG/JPEG) as embedded <image>
2 participants