honza / node-thumbnail

Thumbnail worker queue for node.js
http://honza.ca/node-thumbnail/
Other
103 stars 23 forks source link

No thumbnail produced #17

Closed Ejyption closed 7 years ago

Ejyption commented 7 years ago

I have installed and included the library, all runs fine with source folders and destination folder. As my nodejs server runs it prints out all the names of the images through the node-thumbnail library. The callback prints 'All done!' But no files are in the destination folder.

I am unsure of what the problem could be

honza commented 7 years ago

What version? Master or from the npm distribution?

honza commented 7 years ago

Can you post some sample code to help me debug this?

ntpnhan commented 7 years ago

I encounter the same problem, i install via "npm install node-thumbnail"

honza commented 7 years ago

@ntpnhan Can you post some sample code to help me debug this?

shvhh commented 7 years ago
var fs = require('fs');
var gm = require('gm');
var path  = require("path");
var express = require('express');
var multer  = require('multer');
var app = express();
var storage = multer.diskStorage({
  destination: function(request, files, callback) {
    callback(null,path.join(__dirname, '/uploads'));
  },

  filename: function(request, files, callback) {
    callback(null, Date.now() + files.originalname);
  }

});

var upload = multer({storage: storage});
var thumb = require('node-thumbnail').thumb;
app.use('/static', express.static(path.join(__dirname, 'uploads')))

app.post('/addimg',upload.any(), function (req, res) { 
  thumbnailc(req.files[0].filename);

  res.sendFile(__dirname + '/index.html'); 
});

app.get('/' , function(req,res) {
  res.sendFile(__dirname + '/index.html');
});

// https://github.com/honza/node-thumbnail/issues/17  post a issue on this, everything is fine 
function thumbnailc(name) { 
  thumb({
    source:  'abc.jpg',
    destination:   path.join(__dirname,'uploads/thum'),
    concurrency: 1
  }, function(err) {
    console.log('All done!',err);
  });
};

var server = app.listen(8081, function () {
  var host = server.address().address;
  var port = server.address().port;

   console.log("Example app listening at http://%s:%s", host, port)
});
shvhh commented 7 years ago

help me out

shvhh commented 7 years ago

no output

honza commented 7 years ago

@shvhh Does the destination file exist?

honza commented 7 years ago

I just published 0.8.1 to npm, would you mind trying that? It has better error messages.

shvhh commented 7 years ago

yes it is

Hardik21 commented 7 years ago

I have same problem, How to solve it?

 `thumb({
                source: "./Media/ChatDocUpload/" + _fileName,
                destination: "./Media/ChatDocUpload/" + _fileName,
                concurrency: 1,
                overwrite: true,
                width: 50, height: 50
            }, function (err, stdout, stderr) {
                console.log('All done!');
            });`

This is my code. Function call successfully without error. But not generate Thumb Image.

honza commented 7 years ago

@Hardik21

You should inspect the value of the err argument in the callback to see if any errors occurred. For example:

thumb(options, function(err, stdout, stderr) {
  if (err) {
    throw err;
  }

  console.log('All done!');
});

Also, please note that the source and destination configuration options should point to directories, not files.

Please let me know if you're still having issues. I'm happy to help.

Hardik21 commented 7 years ago

Hi, For 'source': it is filepath with filename. Bcz without filename how to identify image for thumbnail? For 'destination': I set only path without filename. Am i right?

And,

I set

thumb(options, function(err, stdout, stderr) { if (err) { console.log(err); } else console.log('All done!'); });

Then it show in console: 'All done!'. But in destination dir no thumb image generate.

honza commented 7 years ago

Here is my directory structure:

code.js
dest/
package.json
src/
    cat.jpg

Here is package.json:

{
  "name": "test",
  "dependencies": {
    "node-thumbnail": "^0.8.1"
  }
}

Here is code.js:

var thumb = require('node-thumbnail').thumb;

thumb({
  source: 'src/cat.jpg',
  destination: 'dest',
  concurrency: 1,
  overwrite: true,
  width: 50, height: 50
}, function (err, stdout, stderr) {
  console.log('All done!');
});

The src/ direcotory has a single image in it, called cat.jpg.

I install the dependencies with npm install.

Then, I run the code like this:

$ node code.js

Here is the output:

cat.jpg
All done!
all items have been processed

This is with:

Hardik21 commented 7 years ago

I also get that output. But thumb image not generated in destination directory.

honza commented 7 years ago

Can you create a minimal project directory that reproduces this issue, tar it up, and send it to me?

Hardik21 commented 7 years ago

Hi, I upload demo code in Google Drive. Plz download from there and help me to solve.

Click Here for google drive

Thanks

honza commented 7 years ago

Unfortunately, your example works perfectly for me.

honza commented 7 years ago

What is your nodejs and npm version? What operating system are you using?

Hardik21 commented 7 years ago

node: v6.7.0 npm: 4.5.0 OS: Windows 7 64bit

Hardik21 commented 7 years ago

you have generate thumb image in './Media/ChatDocUpload_Thumb/'?

honza commented 7 years ago

I just released version 0.9.0 which removes the dependency on imagemagick. I think that's what is causing the issue on Windows. If you upgrade, you will get a version that's only using Javascript.

Hardik21 commented 7 years ago

Yes. Version 0.9.0 is perfect for windows. Its working awesome. You save my one day. Thanks

honza commented 7 years ago

:sparkles: