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

Resize image without stretch #68

Closed
blowsie opened this issue Nov 25, 2014 · 0 comments
Closed

Resize image without stretch #68

blowsie opened this issue Nov 25, 2014 · 0 comments
Assignees
Milestone

Comments

@blowsie
Copy link

blowsie commented Nov 25, 2014

It would be great if the tool had a function to do something like this. (Resizing without stretching)

        var w = image.width(),
            h = image.height(),
            padX = 0,
            padY = 0;

        if (w > h) {
            padY = [w - h] / 2;
        } else if (h > w) {
            padX = [h - w] / 2;
        }


        image
            .batch()
            .pad(padX, padY, padX, padY, 'white')
            .resize(160,160)

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