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

how can i handle errors while saving an image #7

@pkyeck

Description

@pkyeck

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions