public class ImageSizeSuggestionFactory extends Object
ImageSizeSuggestion
.Modifier and Type | Method and Description |
---|---|
static ImageSizeSuggestion |
create(String suggestion)
Creates a suggestion for how to resize an image.
|
public static ImageSizeSuggestion create(String suggestion) throws SuggestionFormatException
Various suggestions can be specified as follows:
scaleFactor
→ resize to size where width and height are multiplied by
scaleFactor
, preserving aspect ratio e.g. 0.5
or 2
width
xheight
→ resize to a fixed size, without preserving
aspect ratio e.g. 1024x768
width
x → resize to a fixed width, preserving aspect ratio e.g. 1024x
height
→ resize to a fixed height, preserving aspect ratio e.g. x768
width
xheight
+ → resize to maximally contained within a fixed size,
preserving aspect ratio e.g. 1024x768+
A plus at the end can optionally be validly, placed on any of formats which preserve aspect ratio, but not on the second option.
Floating point dimensions are not allowed, so an integer width and height will always be ultimately selected.
suggestion
- a string in the format described above.SuggestionFormatException
- if the suggestion string does not correspond to a
recognized format.Copyright © 2010–2023 Owen Feehan, ETH Zurich, University of Zurich, Hoffmann-La Roche. All rights reserved.