Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

how can i handle errors while saving an image #7

Open
pkyeck opened this Issue · 1 comment

2 participants

Philipp Kyeck Mike Smullin
Philipp Kyeck

i'm trying to create a thumbnail of an image i uploaded to the server:

var w = img.width, h = img.height;

var neww = 75, newh = 75;
var wRatio = (neww / w);
var hRatio = (newh / h);

var cropw, croph;
var srcx = 0, srcy = 0;

if (w > h) {
cropw = Math.round(w * hRatio);
croph = newh;
srcx = Math.ceil( (w - h) / 2);
}
else if (w < h) {
croph = Math.round(h * wRatio);
cropw = neww;
srcy = Math.ceil( (h - w) / 2);
}
else {
cropw = neww;
croph = newh;
}

var target = gd.createTrueColor(neww, newh);
img.copyResampled(target, 0, 0, srcx, srcy, cropw, croph, img.width, img.height);
target.saveJpeg(dest, 90, function() {
// ...
});

the thumbnail isn't created but i don't know why and i don't get an error ... :(

Mike Smullin

still an issue? it is throwing errors fine for me. maybe try the latest version:
https://github.com/mikesmullin/node-gd

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.