Handle vectors (#187)

* Allow loading SVG. Fixes #138.

I also made the resizer vector-aware, so you can resize the image larger & stay sharp.

* Handling SVG without width/height set.

* Simplifying maths

* Doh, case sensitive
This commit is contained in:
Jake Archibald
2018-10-11 14:15:01 +01:00
committed by GitHub
parent 64acc08cd7
commit d2f60baef9
5 changed files with 137 additions and 32 deletions

View File

@@ -4,6 +4,7 @@ import { bind, inputFieldValueAsNumber } from '../../lib/util';
import { ResizeOptions } from './resize';
interface Props {
isVector: Boolean;
options: ResizeOptions;
aspect: number;
onChange(newOptions: ResizeOptions): void;
@@ -63,7 +64,7 @@ export default class ResizerOptions extends Component<Props, State> {
this.form!.width.value = Math.round(height * this.props.aspect);
}
render({ options, aspect }: Props, { maintainAspect }: State) {
render({ options, aspect, isVector }: Props, { maintainAspect }: State) {
return (
<form ref={el => this.form = el}>
<label>
@@ -73,6 +74,7 @@ export default class ResizerOptions extends Component<Props, State> {
value={options.method}
onChange={this.onChange}
>
{isVector && <option value="vector">Vector</option>}
<option value="browser-pixelated">Browser pixelated</option>
<option value="browser-low">Browser low quality</option>
<option value="browser-medium">Browser medium quality</option>