-
Notifications
You must be signed in to change notification settings - Fork 3
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
Make helper methods to load images from any source and convert them into base64 string #7
Comments
I think we could create some Proposed API:
Take note that both methods should return a |
I am grabbing this one. |
Static methods added
|
Sorry for the late reply. Can we chnage the methods to this // I guess you are taking the httpclient from as argument from the user to deal the scenario when the image is behind the authentication.
// if possible can we have enum for httpMethod or some other class
PdfMakeNet.LoadImageFromUrlAsync(Uri imageUrl, SourceImageFormat sourceImageFormat,HttpClient httpClient = new HttpClient(), string httpMethod = "GET");
PdfMakeNet.LoadSvgFromUrlAsync(Uri imageUrl, HttpClient httpClient = new HttpClient(), string httpMethod = "GET");
// Path class has a way to detect the extension for the file so we might not need to take SourceImageFormat
PdfMakeNet.LoadImageFromPath(Path path);
PdfMakeNet.LoadImageFromPath(Path path, SourceImageFormat sourceImageFormat); |
Makes sense for the http methods, but the others from loading from path I think is ok as it is implemented. What we do if an image file is extension less and its still an image? What we do in that situation? The correct way of determine a file type and extension is reading the Your approach from reading the type from extension is ok, few implementations works like that but I prefer explicit image format instead of guessing and also support extension less images. Does this makes sense to you? Do you agree? Reopening. |
In that case, they can use this method PdfMakeNet.LoadImageFromPath(Path path, SourceImageFormat sourceImageFormat);
I do agree that there is some extra read operation but I feel that's worth it. For example, If there is a non-image(or any non-supported image format) file passed to the function we can return the exception saying file not supported. We also need a method to read the |
For reference of implementation |
Loading svg would be as simple as reading it as text, no need for this.
Can svg be binary type? |
Looks promising maybe we can take the implementantion from here only for .jpeg and .png |
Not sure on that one. |
I will do a little bit more of research over this and reply back here with the results and final implementations. |
I guess that answers my question.
Will it be a good idea to have some way of identifying if the string set was a file path and then convert to dataURL internally?
Originally posted by @sc231997 in #6 (comment)
The text was updated successfully, but these errors were encountered: