Skip to content
This repository has been archived by the owner on Mar 31, 2018. It is now read-only.

how can i handle errors while saving an image #7

Open
pkyeck opened this issue Aug 10, 2011 · 1 comment
Open

how can i handle errors while saving an image #7

pkyeck opened this issue Aug 10, 2011 · 1 comment

Comments

@pkyeck
Copy link

pkyeck commented Aug 10, 2011

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 ... :(

@mikesmullin
Copy link

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

zaro referenced this issue in zaro/node-gd Jul 10, 2013
Do not double free when using destroy method
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants