question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error on read function

See original GitHub issue

Expected Behavior

It should resolve the image in promise, but it’s return an error.

Current Behavior

The error I get: TypeError: Cannot read property 'image/jpeg' of undefined

  • Jimp Version: @jimp/types@0.5.4
  • Operating System: Windows
  • Node version: 10.13.0

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:13

github_iconTop GitHub Comments

1reaction
hipstersmoothiecommented, Nov 13, 2018

tsconfig.json

{
  "compilerOptions": {
    "allowJs": true,
    "allowSyntheticDefaultImports": true,
    "baseUrl": ".",
    "jsx": "preserve",
    "lib": ["dom", "es2017"],
    "module": "commonjs",
    "moduleResolution": "node",
    "noEmit": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "preserveConstEnums": true,
    "removeComments": false,
    "skipLibCheck": true,
    "sourceMap": true,
    "strict": true,
    "target": "es5",
    "outDir": "dist",
    "esModuleInterop": true
  },
  "include": ["src/*.ts"]
}

src.ts

import Jimp = require('jimp');

resize('./exampleImages/wings.jpg', 'test.png', {
  width: 500,
  height: 500
});

function resize(
  image: string,
  resizedImage: string,
  size: { width: number; height: number }
) {
  Jimp.read(image)
    .then(img => {
      img.scaleToFit(size.width, size.height).write(resizedImage);
    })
    .catch(console.log);
}

this works as well to so I don’t think it’s typescript

0reactions
RezaT1994commented, Nov 13, 2018

Yes, thank you. solved my problem

Read more comments on GitHub >

github_iconTop Results From Across the Web

read() function error in C - file - Stack Overflow
The most important part of C programming is checking return values. In your sample code sample you do it for open(2) , but...
Read more >
explain_read(3): explain read errors - Linux man page - Die.net
The explain_errno_read function may be used to obtain a human readable explanation of what went wrong in a read(2) system call. The least...
Read more >
read(2) - Linux manual page - man7.org
ERRORS top ... EAGAIN The file descriptor fd refers to a file other than a socket and has been marked nonblocking (O_NONBLOCK), and...
Read more >
TypeError: "x" is read-only - JavaScript - MDN Web Docs
The JavaScript strict mode-only exception "is read-only" occurs when a global variable or object property that was assigned to is a read-only property....
Read more >
Error Codes (The GNU C Library)
Usually used for physical read or write errors. Macro: int ENXIO ¶ ... This condition is detected by the exec functions; see Executing...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found