Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avatar resizing should resize before center+crop #1515

Closed
julianlam opened this issue May 11, 2014 · 0 comments
Closed

Avatar resizing should resize before center+crop #1515

julianlam opened this issue May 11, 2014 · 0 comments
Assignees
Milestone

Comments

@julianlam
Copy link
Member

Right now, the algorithm seems to be finding the center of the image, drawing a square from there, and cropping it. This doesn't maximize the amount of detail, and is unexpected.

The automatic behaviour should resize the entire image first along the smaller dimension (width/height), making sure to maintain aspect ratio. Then to the center+crop magic.

[11:32:02 PM] Trevor: image.resizeImage = function(path, extension, width, height, callback) {
    function done(err, stdout, stderr) {
        callback(err);
    }

    if(extension === '.gif') {
        gm().in(path)
            .in('-coalesce')
            .in('-resize')
            .in(width+'x'+height)
            .write(path, done);
    } else {
        gm(path)
            .gravity('Center')
            .crop(width, height)
            .write(path, done);
    }
};
[11:32:25 PM] Trevor: i feel like something is missing

... snip ✂ snip ...

[11:32:56 PM] Julian Lam: well
[11:32:58 PM] Julian Lam: it's not resizing
[11:33:00 PM] Julian Lam: it's cropping
[11:33:11 PM] Julian Lam: so what should happen instead
[11:33:56 PM] Julian Lam: is it should resize down to the max pixel count along the shortest dimension (e.g. 128x128 and picture is vertical? resize to 128px width)
[11:33:59 PM] Julian Lam: then center and crop.
[11:34:13 PM] Trevor: yes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants