Giter Site home page Giter Site logo

riyadhalnur / node-base64-image Goto Github PK

View Code? Open in Web Editor NEW
132.0 5.0 36.0 1.6 MB

Download images from remote URLs or use local images and encode/decode them to Base64 string or Buffer object

Home Page: http://riyadhalnur.github.io/node-base64-image

License: MIT License

TypeScript 100.00%
javascript nodejs base64 encoder decoder encode decode typescript

node-base64-image's People

Contributors

ceesss avatar dalbodeule avatar dependabot[bot] avatar girliemac avatar ivoba avatar riyadhalnur avatar robbilie avatar salbertson avatar snyk-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

node-base64-image's Issues

Make a new release with all of the dependency updates.

  • node version: 12.14.1
  • npm version: 6.13.7

Error output

  High            Prototype Pollution                                           
                                                                                
  Package         lodash                                                        
                                                                                
  Patched in      >=4.17.12                                                     
                                                                                
  Dependency of   node-base64-image                                             
                                                                                
  Path            node-base64-image > lodash                                    
                                                                                
  More info       https://npmjs.com/advisories/1065    

More details

The fixes have already been merged on master. We just need to make a release for it on NPM.

Screenshot from 2020-02-11 14-11-57

Question - How can I get a wrapped version of base64?

Currently it returns base64 encoded string of an image. It is a long line of a string. In MIME types the base64 encoded strings are wrapped at 76 characters. Any option to directly get that?

For example, there are multiple types of base64 encoded strings. You can find those in the Android Base64 class here. Is there any way to directly get any type of base64 (like wrapped or unwrapped)? If not, any plans to include that?

Error not returned from base64encoder if image doesn't exist

I have encountered this issue when encoding some images from a URL.
I was trialling your component and iterating over an array of images URLs.
The number is encoded strings I received was one less than the number of items in the array.
No error was reported but I found that my source array had a misspelling on one of the images.
The path was correct, the filename was not.

decode adds extension to filename

decode automatically appends an extension to the filename, hard-coded to '.jpg'. This is not a safe assumption to be made as either an extension may already be provided and/or the contents may not be a jpeg image.

local files url not accessing

  • node version: 10.23.0
  • npm version:6.14.8

Error output

ECONNREFUSED

im trying to encode image from local url
const url = 'file:///C:/Users/'my pc user name"/Desktop/ImageDecordEncorder/src/assets/images/example.jpg';

working fine with global url

Support for callback and promises

The title is self explanatory. Essentially, all methods will support promises and callbacks. Enables users to use what suits them best. I don't it's right to enforce a single style in this case. Usability over readability.

Custom headers?

Unless I'm mistaken, you can't pass in custom headers for http requests? Because of this issue I couldn't use this library. maybe other people are in the same boat. Just a heads up.

Cheers

Trying to get in touch with you regarding a security issue

Hi there,

I couldn't find a SECURITY.md in your repository and so am not sure how to best contact you privately to disclose the security issue.

Can you add a SECURITY.md file with your e-mail to your repository, so that I know who to contact? GitHub suggests that a security policy is the best way to make sure security issues are responsibly disclosed.

Once you've done that, please let me know so I can ping you the info.

Thanks! (cc @JamieSlome)

Converting to base64 works fine in development, not in production

  • node version: 8.11.1
  • npm version: 5.6.0

Error output

This is the base64 string for an image in development

iVBORw0KGgoAAAANSUhEUgAAArgAAAOECAIAAADFbdUaAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyZpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3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UyMiUzQSUyMmY2NTU2NGE3MmZiOTEzNzZiNjZiY2ZlZmFhODc4ZjQxMTg4YTEwNTclMjIlMkMlMjJhdXRvdXBkYXRlVmVyc2lvblJlZnJlc2hhYmxlJTIyJTNBJTIyYjYyYTJmNmZhODNiNWQ0YWU4ZGJkMTVkZTNlOTRiMzYzMTEzN2Q5NiUyMiUyQyUyMmF1dG91cGRhdGVWZXJzaW9uQ29yZG92YSUyMiUzQSUyMm5vbmUlMjIlMkMlMjJhY2NvdW50c0NvbmZpZ0NhbGxlZCUyMiUzQXRydWUlN0QiKSk8L3NjcmlwdD4KCiAgPHNjcmlwdCB0eXBlPSJ0ZXh0L2phdmFzY3JpcHQiIHNyYz0iLzE2OTk1ZTE1ZjdjYTBiYWE2YWFiODY1YWQxNjk3ZjNiNzk2ODcwMzQuanM/bWV0ZW9yX2pzX3Jlc291cmNlPXRydWUiPjwvc2NyaXB0PgoKCjwvYm9keT4KPC9odG1sPg==

More details

I use this package in Meteor.js and on the server side, I'm trying to convert the file to base64 string. This, eventually works fine in development and doesn't work in production. Here's the code:

    import { encode, decode } from 'node-base64-image';

    encode(fileUrl, { string: true }, (error, result) => {  // Encodes a remote or local image to Base64 encoded string or Buffer
        if (error) reject(error);
        if (result) resolve(result);
    });

Invalid URI when calling base64.encode

  • node version: v6.10.2
  • npm version: 3.10.10

Error output

 Error: Invalid URI "//cdn.macrumors.com/article-new/2016/01/iOS-9-Siri-250x213.jpg?retina"
    at Request.init (C:\Users\acer\OneDrive\Projects\newsfeed\node_modules\node-base64-image\node_modules\request\request.js:275:31)
    at new Request (C:\Users\acer\OneDrive\Projects\newsfeed\node_modules\node-base64-image\node_modules\request\request.js:129:8)
    at request (C:\Users\acer\OneDrive\Projects\newsfeed\node_modules\node-base64-image\node_modules\request\index.js:55:10)
    at Object.encode (C:\Users\acer\OneDrive\Projects\newsfeed\node_modules\node-base64-image\dist\node-base64-image.js:63:27)
    at Promise (C:\Users\acer\OneDrive\Projects\newsfeed\lib\post.js:48:14)
    at tryCallTwo (C:\Users\acer\OneDrive\Projects\newsfeed\node_modules\promise\lib\core.js:45:5)
    at doResolve (C:\Users\acer\OneDrive\Projects\newsfeed\node_modules\promise\lib\core.js:200:13)
    at new Promise (C:\Users\acer\OneDrive\Projects\newsfeed\node_modules\promise\lib\core.js:66:3)
    at share (C:\Users\acer\OneDrive\Projects\newsfeed\lib\post.js:45:12)
    at Timeout._onTimeout (C:\Users\acer\OneDrive\Projects\newsfeed\share-test.js:45:18)
    at ontimeout (timers.js:380:14)
    at tryOnTimeout (timers.js:244:5)
    at Timer.listOnTimeout (timers.js:214:5)

More details

Error thrown when callin base64.encode passing an URI containing upper cases letters

Is node-base64-image written in typescript?!?!?

  • node version: n/a
  • npm version: n/a

Error output

I am curious: https://github.com/riyadhalnur/node-base64-image/blob/master/src/node-base64-image.js#L27

type Callback<T> = (err: ?Error, x?: T) => void;

export function encode(url: string, options: Object = {string: false, local: false}, callback: Callback<mixed>) {

More details

The code pretty much looks like TypeScript!

But there is no tsconfig.json in the repo, or am I blind? And the code is in a .js file (not a .ts). So what is this?!? I am curious!

ES6 Rewrite

The code as it stands is a bit clunky and all over the place. With a move to ES6, hopefully, the code will be modular and cleaner.

I have started work on this in a separate branch named es6-rewrite which will be merged into master once everything's good to go.

incorrect code in examples

Hi
Thank for you module.
But correct your examples code please.

Ex.1

var options = {string: true}

base64.base64encode('www.someurl.com/image.jpg', function (err, image) {
if (err) { console.log(err); }
console.log(image);
});

MUST

var options = {string: true}

base64.base64encoder('www.someurl.com/image.jpg', options, function (err, image) {
if (err) { console.log(err); }
console.log(image);
});

Ex.2

base64.base64encode( --> base64.base64encoder(

new version to fix vulnerability

if I npm install this package, the following deps get installed as well:

https://nodesecurity.io/advisories/130 advises to upgrade to tough-cookie 2.3 or higher, which [email protected] does.

Although the package.json file was updated to use [email protected], it seems like the npm version itself wasn't (still 1.0.1) so the npm install is still using the 2.72 version of request

Could you publish a new version to fix this vulnerability ?

Thanks

decode

encode outputs either a string or a buffer, while decode only accepts buffers - it should also accept a string for consistency.

Fix server side request forgery vulnerability

  • node version: latest lts
  • npm version: latest lts

Error output

┌───────────────┬──────────────────────────────────────────────────────────────┐
│ High          │ Server-Side Request Forgery                                  │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package       │ axios                                                        │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Patched in    │ >=0.21.1                                                     │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ node-base64-image                                            │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path          │ node-base64-image > axios                                    │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info     │ https://npmjs.com/advisories/1594                            │
└───────────────┴──────────────────────────────────────────────────────────────┘

More details

Should be simple enough, run npm audit fix and publish the patch.

convert img to base64

  • node version:10
  • npm version:"^2.0.1"

I need to convert images to base64. When I do it from my local machine, in debug mode it works perfectly, but when I run the function on GoogleCouldPlatfom, it fails.
Can you please tell me if there are any dependencies or what should I do to make it work ?

let filename = "https://images.nwgmedia.com/Media.aspx?fileId=219135";
const options = {
string: true,
headers: {
"User-Agent": "my-app"
}
};
const base64EncodedImageResponse = await encode(filename, options);

{ Error: Parse Error}

[Suggestion] Return metadata

Hi, I'm using this lib for about 4 months now and the only thing I guess could be improved is a new option param that returns the base64 string + some metadata such as format, maybe its size (width/height), etc.

The format I guess that it's possible to get on the Axios request itself, and the size would be possible to get using something such as probe-image-size.

That's all, cheers.

const response = encode(url, {
    metadata: true, // it could be a better naming fore sure 👍 
})

console.log(response)
/*
 * {
 *     data: <base64>,
 *     format: <jpg, png, etc>,
 *     width: <number>,
 *     height: <number>,
 * }
 */

Public facing API update

At the moment, the 2 main methods are base64encoder and base64decoder. It makes more sense to rename them to encode and decode respectively.

Error: Cannot resolve module 'fs'

  • node version: 9.3.0
  • npm version: 4.6.1

Error output

Module not found: Error: Cannot resolve module 'fs' in E:\R\exclusivi-dashboard\node_modules\node-base64-image\dist

Using it in browser, with webpack-dev-server

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.