'unexpected end of file' with pushing items to an array with jimp
up vote
0
down vote
favorite
i'm trying to overlay multiple images onto one single image. it works to an extent, but it isn't working how i want it to.
global.images = ;
fs.readdirSync('./images').forEach(function(file) {
images.push(file);
if (debug) {
console.log(chalk.green('[Debug] Pushed ' + chalk.blue(file) + ' to the array.'));
}
});
executeEdit(images);
function executeEdit(list) {
var jimps = ;
var x = 0;
for (var i = 0; i < images.length; i++) {
x = x + 150;
setTimeout((function(i) {
return function() {
jimps.push(jimp.read('images/' + images[i]));
}
})(i), 10 * x);
}
this code throws an error of:
(node:15352) UnhandledPromiseRejectionWarning: Error: unexpected end of file
at Inflate.zlibOnError (zlib.js:153:15)
at Inflate._processChunk (D:ImageTestnode_modulespngjslibsync-inflate.js:110:28)
at zlibBufferSync (D:ImageTestnode_modulespngjslibsync-inflate.js:151:17)
at inflateSync (D:ImageTestnode_modulespngjslibsync-inflate.js:155:10)
at module.exports (D:ImageTestnode_modulespngjslibparser-sync.js:79:20)
at Object.exports.read [as image/png] (D:ImageTestnode_modulespngjslibpng-sync.js:10:10)
at Jimp.parseBitmap (D:ImageTestnode_modules@jimpcoredistutilsimage-bitmap.js:117:53)
at Jimp.parseBitmap (D:ImageTestnode_modules@jimpcoredistindex.js:498:32)
at D:ImageTestnode_modules@jimpcoredistindex.js:440:15
at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:511:3)
(node:15352) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
and i have no idea why. it may be due to reading from the directory and adding it to an array as just doing var images = ['file.png', 'file2.png' ]
works fine.
if anyone has any ideas on how to fix, please let me know.
thanks!
edit:
doing this works, but it only chooses the last image and not any others :/
for (var i = 0; i < images.length; i++) {
x = x + 150;
// console.log(i);
var image = {
_integer: i,
_image: images[i],
func: function() {
jimps.push(jimp.read('images/' + this._image));
// console.log(this._integer);
}
}
setTimeout(function() {image.func()}, x);
}
node.js
add a comment |
up vote
0
down vote
favorite
i'm trying to overlay multiple images onto one single image. it works to an extent, but it isn't working how i want it to.
global.images = ;
fs.readdirSync('./images').forEach(function(file) {
images.push(file);
if (debug) {
console.log(chalk.green('[Debug] Pushed ' + chalk.blue(file) + ' to the array.'));
}
});
executeEdit(images);
function executeEdit(list) {
var jimps = ;
var x = 0;
for (var i = 0; i < images.length; i++) {
x = x + 150;
setTimeout((function(i) {
return function() {
jimps.push(jimp.read('images/' + images[i]));
}
})(i), 10 * x);
}
this code throws an error of:
(node:15352) UnhandledPromiseRejectionWarning: Error: unexpected end of file
at Inflate.zlibOnError (zlib.js:153:15)
at Inflate._processChunk (D:ImageTestnode_modulespngjslibsync-inflate.js:110:28)
at zlibBufferSync (D:ImageTestnode_modulespngjslibsync-inflate.js:151:17)
at inflateSync (D:ImageTestnode_modulespngjslibsync-inflate.js:155:10)
at module.exports (D:ImageTestnode_modulespngjslibparser-sync.js:79:20)
at Object.exports.read [as image/png] (D:ImageTestnode_modulespngjslibpng-sync.js:10:10)
at Jimp.parseBitmap (D:ImageTestnode_modules@jimpcoredistutilsimage-bitmap.js:117:53)
at Jimp.parseBitmap (D:ImageTestnode_modules@jimpcoredistindex.js:498:32)
at D:ImageTestnode_modules@jimpcoredistindex.js:440:15
at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:511:3)
(node:15352) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
and i have no idea why. it may be due to reading from the directory and adding it to an array as just doing var images = ['file.png', 'file2.png' ]
works fine.
if anyone has any ideas on how to fix, please let me know.
thanks!
edit:
doing this works, but it only chooses the last image and not any others :/
for (var i = 0; i < images.length; i++) {
x = x + 150;
// console.log(i);
var image = {
_integer: i,
_image: images[i],
func: function() {
jimps.push(jimp.read('images/' + this._image));
// console.log(this._integer);
}
}
setTimeout(function() {image.func()}, x);
}
node.js
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
i'm trying to overlay multiple images onto one single image. it works to an extent, but it isn't working how i want it to.
global.images = ;
fs.readdirSync('./images').forEach(function(file) {
images.push(file);
if (debug) {
console.log(chalk.green('[Debug] Pushed ' + chalk.blue(file) + ' to the array.'));
}
});
executeEdit(images);
function executeEdit(list) {
var jimps = ;
var x = 0;
for (var i = 0; i < images.length; i++) {
x = x + 150;
setTimeout((function(i) {
return function() {
jimps.push(jimp.read('images/' + images[i]));
}
})(i), 10 * x);
}
this code throws an error of:
(node:15352) UnhandledPromiseRejectionWarning: Error: unexpected end of file
at Inflate.zlibOnError (zlib.js:153:15)
at Inflate._processChunk (D:ImageTestnode_modulespngjslibsync-inflate.js:110:28)
at zlibBufferSync (D:ImageTestnode_modulespngjslibsync-inflate.js:151:17)
at inflateSync (D:ImageTestnode_modulespngjslibsync-inflate.js:155:10)
at module.exports (D:ImageTestnode_modulespngjslibparser-sync.js:79:20)
at Object.exports.read [as image/png] (D:ImageTestnode_modulespngjslibpng-sync.js:10:10)
at Jimp.parseBitmap (D:ImageTestnode_modules@jimpcoredistutilsimage-bitmap.js:117:53)
at Jimp.parseBitmap (D:ImageTestnode_modules@jimpcoredistindex.js:498:32)
at D:ImageTestnode_modules@jimpcoredistindex.js:440:15
at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:511:3)
(node:15352) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
and i have no idea why. it may be due to reading from the directory and adding it to an array as just doing var images = ['file.png', 'file2.png' ]
works fine.
if anyone has any ideas on how to fix, please let me know.
thanks!
edit:
doing this works, but it only chooses the last image and not any others :/
for (var i = 0; i < images.length; i++) {
x = x + 150;
// console.log(i);
var image = {
_integer: i,
_image: images[i],
func: function() {
jimps.push(jimp.read('images/' + this._image));
// console.log(this._integer);
}
}
setTimeout(function() {image.func()}, x);
}
node.js
i'm trying to overlay multiple images onto one single image. it works to an extent, but it isn't working how i want it to.
global.images = ;
fs.readdirSync('./images').forEach(function(file) {
images.push(file);
if (debug) {
console.log(chalk.green('[Debug] Pushed ' + chalk.blue(file) + ' to the array.'));
}
});
executeEdit(images);
function executeEdit(list) {
var jimps = ;
var x = 0;
for (var i = 0; i < images.length; i++) {
x = x + 150;
setTimeout((function(i) {
return function() {
jimps.push(jimp.read('images/' + images[i]));
}
})(i), 10 * x);
}
this code throws an error of:
(node:15352) UnhandledPromiseRejectionWarning: Error: unexpected end of file
at Inflate.zlibOnError (zlib.js:153:15)
at Inflate._processChunk (D:ImageTestnode_modulespngjslibsync-inflate.js:110:28)
at zlibBufferSync (D:ImageTestnode_modulespngjslibsync-inflate.js:151:17)
at inflateSync (D:ImageTestnode_modulespngjslibsync-inflate.js:155:10)
at module.exports (D:ImageTestnode_modulespngjslibparser-sync.js:79:20)
at Object.exports.read [as image/png] (D:ImageTestnode_modulespngjslibpng-sync.js:10:10)
at Jimp.parseBitmap (D:ImageTestnode_modules@jimpcoredistutilsimage-bitmap.js:117:53)
at Jimp.parseBitmap (D:ImageTestnode_modules@jimpcoredistindex.js:498:32)
at D:ImageTestnode_modules@jimpcoredistindex.js:440:15
at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:511:3)
(node:15352) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
and i have no idea why. it may be due to reading from the directory and adding it to an array as just doing var images = ['file.png', 'file2.png' ]
works fine.
if anyone has any ideas on how to fix, please let me know.
thanks!
edit:
doing this works, but it only chooses the last image and not any others :/
for (var i = 0; i < images.length; i++) {
x = x + 150;
// console.log(i);
var image = {
_integer: i,
_image: images[i],
func: function() {
jimps.push(jimp.read('images/' + this._image));
// console.log(this._integer);
}
}
setTimeout(function() {image.func()}, x);
}
node.js
node.js
edited 2 days ago
asked 2 days ago
Joe Stevens
105
105
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
The hint is the message UnhandledPromiseRejectionWarning
: you are missing the fact that jimp
is actually asynchronous (either callbacks or promises). In your case, since there is no callback passed to jimp.read()
it assumes promises are used but you are not using them correctly.
If you replace // console.log(this._integer);
by console.log(jimps)
, you will see something like this:
[ Promise { <pending> } ]
[ Promise { <Jimp 32x32> }, Promise { <pending> } ]
....
I am not sure what you are doing with the jimps
array at all (nor why you are using a setTimeout()
here), but you can perhaps do something like this (if have simplified a bit by removing some logs and removing the setTimeout()
stuff). This is now proper promise code.
var fs = require('fs');
var jimp = require('jimp');
const images = ;
fs.readdirSync('./images').forEach(function(file) {
images.push(file);
console.log('[Debug] Pushed', file, ' to the array');
});
executeEdit(images);
console.log('waiting for executeEdit() to terminate');
function executeEdit(list) {
let jimp_read_promises =
for (var i = 0; i < images.length; i++) {
jimp_read_promises.push( jimp.read('images/' + images[i]))
}
Promise.all(jimp_read_promises).then( loadedimgs => {
loadedimgs.map( img => {
console.log( img )
})
})
}
So this would print the following
[Debug] Pushed 7035a55d06033e435be112c0969b1820.png to the array
[Debug] Pushed aa5ef861d490a11fe20806e83c6dc64b.png to the array
[Debug] Pushed crayon.png to the array
waiting for executeEdit() to terminate
<Jimp 32x32>
<Jimp 48x48>
<Jimp 256x256>
So the 3 files (in my case) are read synchronously then executeEdit() is called. We build an array of promise objects then call Promise.all() which will wait till all promises are resolved. The value loadedimgs
is an array with the result of each promise (in the same order as the promises). You can then loop over that array as you see fit (here I used a map
call but a for loop will do.
I hope this helps.
thanks for the response! however, i am encountering problems when running this code. i still get the same errorunexpected end of file
and also the errorawait jimp.read('images/' + images[i]) ^^^^^ SyntaxError: await is only valid in async function
. here is my current code: pastebin.com/raw/CsgPii9B - if you would have any idea on how to fix this, it would really help :^)
– Joe Stevens
2 days ago
could the unexpected end of file be due to one of your image being incorrect or corrupted ? Also can you tell me which version of node you are using ? The code I pasted was in a file calledtest.js
which I ran withnode test.js
without issue. My version of node is v10.8.0. I will look at the pastebin.
– tgo
2 days ago
it might be to do with the version of node im using: im onv8.11.2
://
– Joe Stevens
2 days ago
this is weird. I just installed v8.11.2 and run the file from pastebin unchanged. and I don't get any error message of any king neither releated to async nor to unexpected eof :( The output is here pastebin.com/raw/pJAkZ7zf (the undefined are normals as image[i] is not valid anymore by the time the promise is handled) Can you try with a few different images (incl. background) just to be sure ?
– tgo
2 days ago
ill quickly make a youtube video that showcases my issue gimme a min
– Joe Stevens
2 days ago
|
show 10 more comments
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
The hint is the message UnhandledPromiseRejectionWarning
: you are missing the fact that jimp
is actually asynchronous (either callbacks or promises). In your case, since there is no callback passed to jimp.read()
it assumes promises are used but you are not using them correctly.
If you replace // console.log(this._integer);
by console.log(jimps)
, you will see something like this:
[ Promise { <pending> } ]
[ Promise { <Jimp 32x32> }, Promise { <pending> } ]
....
I am not sure what you are doing with the jimps
array at all (nor why you are using a setTimeout()
here), but you can perhaps do something like this (if have simplified a bit by removing some logs and removing the setTimeout()
stuff). This is now proper promise code.
var fs = require('fs');
var jimp = require('jimp');
const images = ;
fs.readdirSync('./images').forEach(function(file) {
images.push(file);
console.log('[Debug] Pushed', file, ' to the array');
});
executeEdit(images);
console.log('waiting for executeEdit() to terminate');
function executeEdit(list) {
let jimp_read_promises =
for (var i = 0; i < images.length; i++) {
jimp_read_promises.push( jimp.read('images/' + images[i]))
}
Promise.all(jimp_read_promises).then( loadedimgs => {
loadedimgs.map( img => {
console.log( img )
})
})
}
So this would print the following
[Debug] Pushed 7035a55d06033e435be112c0969b1820.png to the array
[Debug] Pushed aa5ef861d490a11fe20806e83c6dc64b.png to the array
[Debug] Pushed crayon.png to the array
waiting for executeEdit() to terminate
<Jimp 32x32>
<Jimp 48x48>
<Jimp 256x256>
So the 3 files (in my case) are read synchronously then executeEdit() is called. We build an array of promise objects then call Promise.all() which will wait till all promises are resolved. The value loadedimgs
is an array with the result of each promise (in the same order as the promises). You can then loop over that array as you see fit (here I used a map
call but a for loop will do.
I hope this helps.
thanks for the response! however, i am encountering problems when running this code. i still get the same errorunexpected end of file
and also the errorawait jimp.read('images/' + images[i]) ^^^^^ SyntaxError: await is only valid in async function
. here is my current code: pastebin.com/raw/CsgPii9B - if you would have any idea on how to fix this, it would really help :^)
– Joe Stevens
2 days ago
could the unexpected end of file be due to one of your image being incorrect or corrupted ? Also can you tell me which version of node you are using ? The code I pasted was in a file calledtest.js
which I ran withnode test.js
without issue. My version of node is v10.8.0. I will look at the pastebin.
– tgo
2 days ago
it might be to do with the version of node im using: im onv8.11.2
://
– Joe Stevens
2 days ago
this is weird. I just installed v8.11.2 and run the file from pastebin unchanged. and I don't get any error message of any king neither releated to async nor to unexpected eof :( The output is here pastebin.com/raw/pJAkZ7zf (the undefined are normals as image[i] is not valid anymore by the time the promise is handled) Can you try with a few different images (incl. background) just to be sure ?
– tgo
2 days ago
ill quickly make a youtube video that showcases my issue gimme a min
– Joe Stevens
2 days ago
|
show 10 more comments
up vote
0
down vote
accepted
The hint is the message UnhandledPromiseRejectionWarning
: you are missing the fact that jimp
is actually asynchronous (either callbacks or promises). In your case, since there is no callback passed to jimp.read()
it assumes promises are used but you are not using them correctly.
If you replace // console.log(this._integer);
by console.log(jimps)
, you will see something like this:
[ Promise { <pending> } ]
[ Promise { <Jimp 32x32> }, Promise { <pending> } ]
....
I am not sure what you are doing with the jimps
array at all (nor why you are using a setTimeout()
here), but you can perhaps do something like this (if have simplified a bit by removing some logs and removing the setTimeout()
stuff). This is now proper promise code.
var fs = require('fs');
var jimp = require('jimp');
const images = ;
fs.readdirSync('./images').forEach(function(file) {
images.push(file);
console.log('[Debug] Pushed', file, ' to the array');
});
executeEdit(images);
console.log('waiting for executeEdit() to terminate');
function executeEdit(list) {
let jimp_read_promises =
for (var i = 0; i < images.length; i++) {
jimp_read_promises.push( jimp.read('images/' + images[i]))
}
Promise.all(jimp_read_promises).then( loadedimgs => {
loadedimgs.map( img => {
console.log( img )
})
})
}
So this would print the following
[Debug] Pushed 7035a55d06033e435be112c0969b1820.png to the array
[Debug] Pushed aa5ef861d490a11fe20806e83c6dc64b.png to the array
[Debug] Pushed crayon.png to the array
waiting for executeEdit() to terminate
<Jimp 32x32>
<Jimp 48x48>
<Jimp 256x256>
So the 3 files (in my case) are read synchronously then executeEdit() is called. We build an array of promise objects then call Promise.all() which will wait till all promises are resolved. The value loadedimgs
is an array with the result of each promise (in the same order as the promises). You can then loop over that array as you see fit (here I used a map
call but a for loop will do.
I hope this helps.
thanks for the response! however, i am encountering problems when running this code. i still get the same errorunexpected end of file
and also the errorawait jimp.read('images/' + images[i]) ^^^^^ SyntaxError: await is only valid in async function
. here is my current code: pastebin.com/raw/CsgPii9B - if you would have any idea on how to fix this, it would really help :^)
– Joe Stevens
2 days ago
could the unexpected end of file be due to one of your image being incorrect or corrupted ? Also can you tell me which version of node you are using ? The code I pasted was in a file calledtest.js
which I ran withnode test.js
without issue. My version of node is v10.8.0. I will look at the pastebin.
– tgo
2 days ago
it might be to do with the version of node im using: im onv8.11.2
://
– Joe Stevens
2 days ago
this is weird. I just installed v8.11.2 and run the file from pastebin unchanged. and I don't get any error message of any king neither releated to async nor to unexpected eof :( The output is here pastebin.com/raw/pJAkZ7zf (the undefined are normals as image[i] is not valid anymore by the time the promise is handled) Can you try with a few different images (incl. background) just to be sure ?
– tgo
2 days ago
ill quickly make a youtube video that showcases my issue gimme a min
– Joe Stevens
2 days ago
|
show 10 more comments
up vote
0
down vote
accepted
up vote
0
down vote
accepted
The hint is the message UnhandledPromiseRejectionWarning
: you are missing the fact that jimp
is actually asynchronous (either callbacks or promises). In your case, since there is no callback passed to jimp.read()
it assumes promises are used but you are not using them correctly.
If you replace // console.log(this._integer);
by console.log(jimps)
, you will see something like this:
[ Promise { <pending> } ]
[ Promise { <Jimp 32x32> }, Promise { <pending> } ]
....
I am not sure what you are doing with the jimps
array at all (nor why you are using a setTimeout()
here), but you can perhaps do something like this (if have simplified a bit by removing some logs and removing the setTimeout()
stuff). This is now proper promise code.
var fs = require('fs');
var jimp = require('jimp');
const images = ;
fs.readdirSync('./images').forEach(function(file) {
images.push(file);
console.log('[Debug] Pushed', file, ' to the array');
});
executeEdit(images);
console.log('waiting for executeEdit() to terminate');
function executeEdit(list) {
let jimp_read_promises =
for (var i = 0; i < images.length; i++) {
jimp_read_promises.push( jimp.read('images/' + images[i]))
}
Promise.all(jimp_read_promises).then( loadedimgs => {
loadedimgs.map( img => {
console.log( img )
})
})
}
So this would print the following
[Debug] Pushed 7035a55d06033e435be112c0969b1820.png to the array
[Debug] Pushed aa5ef861d490a11fe20806e83c6dc64b.png to the array
[Debug] Pushed crayon.png to the array
waiting for executeEdit() to terminate
<Jimp 32x32>
<Jimp 48x48>
<Jimp 256x256>
So the 3 files (in my case) are read synchronously then executeEdit() is called. We build an array of promise objects then call Promise.all() which will wait till all promises are resolved. The value loadedimgs
is an array with the result of each promise (in the same order as the promises). You can then loop over that array as you see fit (here I used a map
call but a for loop will do.
I hope this helps.
The hint is the message UnhandledPromiseRejectionWarning
: you are missing the fact that jimp
is actually asynchronous (either callbacks or promises). In your case, since there is no callback passed to jimp.read()
it assumes promises are used but you are not using them correctly.
If you replace // console.log(this._integer);
by console.log(jimps)
, you will see something like this:
[ Promise { <pending> } ]
[ Promise { <Jimp 32x32> }, Promise { <pending> } ]
....
I am not sure what you are doing with the jimps
array at all (nor why you are using a setTimeout()
here), but you can perhaps do something like this (if have simplified a bit by removing some logs and removing the setTimeout()
stuff). This is now proper promise code.
var fs = require('fs');
var jimp = require('jimp');
const images = ;
fs.readdirSync('./images').forEach(function(file) {
images.push(file);
console.log('[Debug] Pushed', file, ' to the array');
});
executeEdit(images);
console.log('waiting for executeEdit() to terminate');
function executeEdit(list) {
let jimp_read_promises =
for (var i = 0; i < images.length; i++) {
jimp_read_promises.push( jimp.read('images/' + images[i]))
}
Promise.all(jimp_read_promises).then( loadedimgs => {
loadedimgs.map( img => {
console.log( img )
})
})
}
So this would print the following
[Debug] Pushed 7035a55d06033e435be112c0969b1820.png to the array
[Debug] Pushed aa5ef861d490a11fe20806e83c6dc64b.png to the array
[Debug] Pushed crayon.png to the array
waiting for executeEdit() to terminate
<Jimp 32x32>
<Jimp 48x48>
<Jimp 256x256>
So the 3 files (in my case) are read synchronously then executeEdit() is called. We build an array of promise objects then call Promise.all() which will wait till all promises are resolved. The value loadedimgs
is an array with the result of each promise (in the same order as the promises). You can then loop over that array as you see fit (here I used a map
call but a for loop will do.
I hope this helps.
edited 2 days ago
answered 2 days ago
tgo
1,185511
1,185511
thanks for the response! however, i am encountering problems when running this code. i still get the same errorunexpected end of file
and also the errorawait jimp.read('images/' + images[i]) ^^^^^ SyntaxError: await is only valid in async function
. here is my current code: pastebin.com/raw/CsgPii9B - if you would have any idea on how to fix this, it would really help :^)
– Joe Stevens
2 days ago
could the unexpected end of file be due to one of your image being incorrect or corrupted ? Also can you tell me which version of node you are using ? The code I pasted was in a file calledtest.js
which I ran withnode test.js
without issue. My version of node is v10.8.0. I will look at the pastebin.
– tgo
2 days ago
it might be to do with the version of node im using: im onv8.11.2
://
– Joe Stevens
2 days ago
this is weird. I just installed v8.11.2 and run the file from pastebin unchanged. and I don't get any error message of any king neither releated to async nor to unexpected eof :( The output is here pastebin.com/raw/pJAkZ7zf (the undefined are normals as image[i] is not valid anymore by the time the promise is handled) Can you try with a few different images (incl. background) just to be sure ?
– tgo
2 days ago
ill quickly make a youtube video that showcases my issue gimme a min
– Joe Stevens
2 days ago
|
show 10 more comments
thanks for the response! however, i am encountering problems when running this code. i still get the same errorunexpected end of file
and also the errorawait jimp.read('images/' + images[i]) ^^^^^ SyntaxError: await is only valid in async function
. here is my current code: pastebin.com/raw/CsgPii9B - if you would have any idea on how to fix this, it would really help :^)
– Joe Stevens
2 days ago
could the unexpected end of file be due to one of your image being incorrect or corrupted ? Also can you tell me which version of node you are using ? The code I pasted was in a file calledtest.js
which I ran withnode test.js
without issue. My version of node is v10.8.0. I will look at the pastebin.
– tgo
2 days ago
it might be to do with the version of node im using: im onv8.11.2
://
– Joe Stevens
2 days ago
this is weird. I just installed v8.11.2 and run the file from pastebin unchanged. and I don't get any error message of any king neither releated to async nor to unexpected eof :( The output is here pastebin.com/raw/pJAkZ7zf (the undefined are normals as image[i] is not valid anymore by the time the promise is handled) Can you try with a few different images (incl. background) just to be sure ?
– tgo
2 days ago
ill quickly make a youtube video that showcases my issue gimme a min
– Joe Stevens
2 days ago
thanks for the response! however, i am encountering problems when running this code. i still get the same error
unexpected end of file
and also the error await jimp.read('images/' + images[i]) ^^^^^ SyntaxError: await is only valid in async function
. here is my current code: pastebin.com/raw/CsgPii9B - if you would have any idea on how to fix this, it would really help :^)– Joe Stevens
2 days ago
thanks for the response! however, i am encountering problems when running this code. i still get the same error
unexpected end of file
and also the error await jimp.read('images/' + images[i]) ^^^^^ SyntaxError: await is only valid in async function
. here is my current code: pastebin.com/raw/CsgPii9B - if you would have any idea on how to fix this, it would really help :^)– Joe Stevens
2 days ago
could the unexpected end of file be due to one of your image being incorrect or corrupted ? Also can you tell me which version of node you are using ? The code I pasted was in a file called
test.js
which I ran with node test.js
without issue. My version of node is v10.8.0. I will look at the pastebin.– tgo
2 days ago
could the unexpected end of file be due to one of your image being incorrect or corrupted ? Also can you tell me which version of node you are using ? The code I pasted was in a file called
test.js
which I ran with node test.js
without issue. My version of node is v10.8.0. I will look at the pastebin.– tgo
2 days ago
it might be to do with the version of node im using: im on
v8.11.2
://– Joe Stevens
2 days ago
it might be to do with the version of node im using: im on
v8.11.2
://– Joe Stevens
2 days ago
this is weird. I just installed v8.11.2 and run the file from pastebin unchanged. and I don't get any error message of any king neither releated to async nor to unexpected eof :( The output is here pastebin.com/raw/pJAkZ7zf (the undefined are normals as image[i] is not valid anymore by the time the promise is handled) Can you try with a few different images (incl. background) just to be sure ?
– tgo
2 days ago
this is weird. I just installed v8.11.2 and run the file from pastebin unchanged. and I don't get any error message of any king neither releated to async nor to unexpected eof :( The output is here pastebin.com/raw/pJAkZ7zf (the undefined are normals as image[i] is not valid anymore by the time the promise is handled) Can you try with a few different images (incl. background) just to be sure ?
– tgo
2 days ago
ill quickly make a youtube video that showcases my issue gimme a min
– Joe Stevens
2 days ago
ill quickly make a youtube video that showcases my issue gimme a min
– Joe Stevens
2 days ago
|
show 10 more comments
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53239152%2funexpected-end-of-file-with-pushing-items-to-an-array-with-jimp%23new-answer', 'question_page');
}
);
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password