Git Product home page Git Product logo

js-image-generator's People

Contributors

ashupp avatar progi1984 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

Watchers

 avatar  avatar

js-image-generator's Issues

typescript compilation failed

node_modules/js-image-generator/index.d.ts:5:13 - error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type.

5   callback: function(Error|null, RawImageData<Buffer>)
              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/js-image-generator/index.d.ts:5:13 - error TS8020: JSDoc types can only be used inside documentation comments.

5   callback: function(Error|null, RawImageData<Buffer>)
              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/js-image-generator/index.d.ts:5:34 - error TS2552: Cannot find name 'RawImageData'. Did you mean 'ImageData'?

5   callback: function(Error|null, RawImageData<Buffer>)
                                   ~~~~~~~~~~~~

  node_modules/typescript/lib/lib.dom.d.ts:9123:13
    9123 declare var ImageData: {
                     ~~~~~~~~~
    'ImageData' is declared here.

index.d.ts should be something alone the lines of

export interface RawImageData<T> { 
  data: T;
}

export declare function generateImage(
  width: number,
  height: number,
  quality: number,
  callback: (error: Error | null, imageData: RawImageData<Buffer>) => any
): void

Successive calls get slower and slower

Successive calls to generateImage keep getting slower, up to a max of about 7 seconds per call.

The following code:

let now = Date.now();
for(var i = 0; i < 1000; i++){
imgGen.generateImage(2000,2000,80, function(err, image){
console.log(i, (now - (now = Date.now())) * -1 + ' ms');//calculate and reassign both at once
});
}

Results in the following output:

0 '1024 ms'
1 '1060 ms'
2 '1079 ms'
3 '1045 ms'
4 '1089 ms'
5 '1051 ms'
6 '1122 ms'
7 '1142 ms'
8 '1900 ms'
9 '1919 ms'
10 '1943 ms'
11 '2016 ms'
12 '2043 ms'
13 '2057 ms'
14 '2712 ms'
15 '3323 ms'
16 '5265 ms'
17 '5340 ms'
18 '7192 ms'
19 '7220 ms'
20 '7184 ms'

It stays at around 7.2 seconds after that.

If I have some time, I'll clone your code and see if I can figure out what's going on.

(PS: Thanks for creating this module)

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.