Comments (9)
Not sure what you mean that GraphicsMagick doesn't support this. You'd only append a >
at the end of the -resize
argument, for example 400x400>
.
Do you want a PR for this? It's a breaking change, but IMHO with the current API I would not expect it scaling up when passing maxWidth/Height arguments hence it's a bug that needs fixing rather than breaking current behavior.
from node-s3-uploader.
This is currently not supported. s3-uploader is using gm under the hood, aheckmann/gm#226 discusses this functionality.
from node-s3-uploader.
I think your library can support that with some checking. I don't know coffee script, so I give some pseudo code in node as example.
var resizeWith = version.maxWidth;
var resizeHeight = version.maxHeight;
if (!version.force && self.meta && self.meta.imageSize) {
if (version.maxWidth > self.meta.imageSize.width) {
resizeWith = self.meta.imageSize.width;
}
if (version.maxHeight > self.meta.imageSize.height) {
resizeHeight = self.meta.imageSize.height;
}
}
var img = mpc.resize(resizeWith, resizeHeight, '^')
.gravity('Center')
.crop(resizeWith, resizeHeight)
.quality(version.quality || self.config.opts.resizeQuality);
The version.force = true will indicate that user want to scale up if the image size was smaller than the configuration size. The '^' will make the image is resized while maintaining the aspect ratio of the image, but the resulting width or height are treated as minimum values rather than maximum values.
from node-s3-uploader.
The short answer is yes, I would want a PR for this.
The long answer is that this is outside of what I need from s3-uploader
so I will not have the time to do this myself.
Since this issue first was opened we have refactored away from gm
so most of the functionality would need to go in im-resize
package. Also aspectratio
would need a corresponding change to calculate correct image size based on this new logic. It currently assumes that the image will be scaled up if it is smaller than the max width / height option.
from node-s3-uploader.
@Starefossen: no worries, already did those changes locally for im-resize
can do it for aspectratio too. Question is if you're willing to merge a breaking change. Replied here since there was no issue and very low activity in the im-resize
repo.
from node-s3-uploader.
By the way, wouldn't it be better to rely on identify
or similar than to get actual dimensions rather than precalculate them?
from node-s3-uploader.
Yes, I am willing to merge this breaking change as long as the existing behavior can be enabled with an option.
It would be easier to use ImageMagics's identify
command, but it will also be much much slower since it requires reading each image version from disk in order to return the size of it.
from node-s3-uploader.
identify
would be more accurate since rounding and resizing algorithms might differ between im-resize
and Image/GraphicsMagick. Slower, sure, but in the context of manipulating images and sending them to S3 it's probably negligible unless you're at Facebook scale.
If you think aspectratio
is the way to go I'll do it :-)
from node-s3-uploader.
Yes, for the time being I think aspectratio
is the right way to go. I welcome any PR for that 👍
from node-s3-uploader.
Related Issues (20)
- I don't want to upload the original image. HOT 1
- Unable to parse path with space HOT 2
- How to use with form upload and express 4? HOT 5
- File type .xcf (GIMP file) causing uncatchable error HOT 1
- TimeoutError: Connection timed out after 10000ms HOT 5
- Creating image version without specifying max-width (original size), results in smaller image file size (lesser quality?) than a smaller px image? HOT 2
- The authorization mechanism you have provided is not supported HOT 3
- if crop the image with width and aspect ration, how to define from the center/top/down as the position to crop? Thanks. HOT 1
- Feature request / docs request - Usage with Node.js streams HOT 2
- Add ImageMagick installation instructions
- Original uploaded image does not have an extension when the path is specified HOT 2
- client.upload() getting error
- original version removed still with cleanup false in configuration
- Is there a way to generate progressive jpeg versions?
- upload error: convert failed
- It doesn't return or upload original image
- [Feature Request] - Proxy Support
- Problem with ImageMagick 7.x
- Please help more than once but it is the same result
- TimeoutError: Missing credentials in config HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-s3-uploader.