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

Add option "extension" to "imageVersions" to convert upload #32

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

naholyr
Copy link

@naholyr naholyr commented Oct 18, 2013

Automatically convert to given extension using following syntax:

imageVersions: {
  thumbnail: {
    width: 80,
    height: 80,
    extension: "png"
  }
}

Automatically convert to given extension using following syntax:

```javascript
imageVersions: {
  thumbnail: {
    width: 80,
    height: 80,
    extension: "png"
  }
}
```
@yorele
Copy link

yorele commented Mar 29, 2016

the res.json() is a valid issue.

As for extension, you can do this directly with the uploader.on('begin'): changing the extension on the file name there and imageMagick will do the conversion for you if the extension is set.

uploader.on('begin', function (fileInfo, req, res) {
    fileInfo.name = xxxxx; //<--- set the extension the way you want here.
});

You can also set all sorts of options with the imageArgs option:
Like here I crop centered the image to 150x150

imageVersions: {
        small: {
            width: "150",
            height: "150^",
            imageArgs: ['-gravity', 'Center', '-crop', '150x150+0+0', '-format', 'JPG']
        }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants