mirror of
https://github.com/GoogleChromeLabs/squoosh.git
synced 2025-11-14 01:37:26 +00:00
Optipng (#156)
* omg it’s compiling * example actually works * Expose compression level options * Disable crypto and path module emulation in webpack * Update README * Remove small image * Use -O3 on optipng * Free memory after copy * Handle unexpected file reader return types * Rename level label to effort
This commit is contained in:
39
src/codecs/optipng/options.tsx
Normal file
39
src/codecs/optipng/options.tsx
Normal file
@@ -0,0 +1,39 @@
|
||||
import { h, Component } from 'preact';
|
||||
import { bind, inputFieldValueAsNumber } from '../../lib/util';
|
||||
import { EncodeOptions } from './encoder';
|
||||
|
||||
type Props = {
|
||||
options: EncodeOptions;
|
||||
onChange(newOptions: EncodeOptions): void;
|
||||
};
|
||||
|
||||
export default class OptiPNGEncoderOptions extends Component<Props, {}> {
|
||||
@bind
|
||||
onChange(event: Event) {
|
||||
const form = (event.currentTarget as HTMLInputElement).closest('form') as HTMLFormElement;
|
||||
|
||||
const options: EncodeOptions = {
|
||||
level: inputFieldValueAsNumber(form.level),
|
||||
};
|
||||
this.props.onChange(options);
|
||||
}
|
||||
|
||||
render({ options }: Props) {
|
||||
return (
|
||||
<form>
|
||||
<label>
|
||||
Effort:
|
||||
<input
|
||||
name="level"
|
||||
type="range"
|
||||
min="0"
|
||||
max="7"
|
||||
step="1"
|
||||
value={'' + options.level}
|
||||
onChange={this.onChange}
|
||||
/>
|
||||
</label>
|
||||
</form>
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user