mirror of
https://github.com/GoogleChromeLabs/squoosh.git
synced 2025-11-13 01:07:18 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
26e9a848dd |
@@ -1,8 +1,7 @@
|
|||||||
FROM ubuntu
|
FROM ubuntu
|
||||||
RUN apt-get update && \
|
RUN apt-get update && \
|
||||||
apt-get install -qqy git build-essential cmake python2.7
|
apt-get install -qqy git build-essential cmake python2.7
|
||||||
|
RUN git clone --recursive https://github.com/WebAssembly/wabt /usr/src/wabt
|
||||||
RUN git clone --depth 1 --recursive https://github.com/WebAssembly/wabt /usr/src/wabt
|
|
||||||
RUN mkdir -p /usr/src/wabt/build
|
RUN mkdir -p /usr/src/wabt/build
|
||||||
WORKDIR /usr/src/wabt/build
|
WORKDIR /usr/src/wabt/build
|
||||||
RUN cmake .. -DCMAKE_INSTALL_PREFIX=/opt/wabt && \
|
RUN cmake .. -DCMAKE_INSTALL_PREFIX=/opt/wabt && \
|
||||||
@@ -15,7 +14,10 @@ RUN rustup install nightly && \
|
|||||||
cargo install wasm-pack
|
cargo install wasm-pack
|
||||||
|
|
||||||
COPY --from=0 /opt/wabt /opt/wabt
|
COPY --from=0 /opt/wabt /opt/wabt
|
||||||
|
|
||||||
RUN mkdir /opt/binaryen && \
|
RUN mkdir /opt/binaryen && \
|
||||||
curl -L https://github.com/WebAssembly/binaryen/releases/download/1.38.32/binaryen-1.38.32-x86-linux.tar.gz | tar -xzf - -C /opt/binaryen --strip 1
|
curl -L https://github.com/WebAssembly/binaryen/releases/download/1.38.32/binaryen-1.38.32-x86-linux.tar.gz | tar -xzf - -C /opt/binaryen --strip 1
|
||||||
|
|
||||||
ENV PATH="/opt/binaryen:/opt/wabt/bin:${PATH}"
|
ENV PATH="/opt/binaryen:/opt/wabt/bin:${PATH}"
|
||||||
|
|
||||||
WORKDIR /src
|
WORKDIR /src
|
||||||
|
|||||||
@@ -8,10 +8,9 @@ echo "============================================="
|
|||||||
(
|
(
|
||||||
rustup run nightly \
|
rustup run nightly \
|
||||||
wasm-pack build --target no-modules
|
wasm-pack build --target no-modules
|
||||||
|
mv pkg/squooshhqx_bg.wasm pkg/squooshhqx_bg.unopt.wasm
|
||||||
|
wasm-opt -Os --no-validation pkg/squooshhqx_bg.unopt.wasm -o pkg/squooshhqx_bg.wasm
|
||||||
wasm-strip pkg/squooshhqx_bg.wasm
|
wasm-strip pkg/squooshhqx_bg.wasm
|
||||||
echo "Optimising WASM so it doesn't break Chrome (this takes like 10-15mins. get a cup of tea)"
|
|
||||||
echo "Once https://bugs.chromium.org/p/chromium/issues/detail?id=97480 is fixed, we can remove this step"
|
|
||||||
wasm-opt -Os --no-validation -o pkg/squooshhqx_bg.wasm pkg/squooshhqx_bg.wasm
|
|
||||||
rm pkg/.gitignore
|
rm pkg/.gitignore
|
||||||
)
|
)
|
||||||
echo "============================================="
|
echo "============================================="
|
||||||
|
|||||||
11
codecs/hqx/loading_benchmark.js
Normal file
11
codecs/hqx/loading_benchmark.js
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
// THIS IS NOT A NODE SCRIPT
|
||||||
|
// This is a d8 script. Please install jsvu[1] and install v8.
|
||||||
|
// Then run `npm run --silent benchmark`.
|
||||||
|
// [1]: https://github.com/GoogleChromeLabs/jsvu
|
||||||
|
|
||||||
|
async function init() {
|
||||||
|
const start = Date.now();
|
||||||
|
const module = await WebAssembly.compile(readbuffer("pkg/squooshhqx_bg.wasm"));
|
||||||
|
print(`${Date.now()/1000 - start/1000}`);
|
||||||
|
}
|
||||||
|
init().catch(e => console.error(e.stack));
|
||||||
Binary file not shown.
2
package-lock.json
generated
2
package-lock.json
generated
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "squoosh",
|
"name": "squoosh",
|
||||||
"version": "1.8.1",
|
"version": "1.8.0",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"private": true,
|
"private": true,
|
||||||
"name": "squoosh",
|
"name": "squoosh",
|
||||||
"version": "1.8.1",
|
"version": "1.8.0",
|
||||||
"license": "apache-2.0",
|
"license": "apache-2.0",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "webpack-dev-server --host 0.0.0.0 --hot",
|
"start": "webpack-dev-server --host 0.0.0.0 --hot",
|
||||||
|
|||||||
@@ -24,6 +24,19 @@ interface State {
|
|||||||
|
|
||||||
const sizePresets = [0.25, 0.3333, 0.5, 1, 2, 3, 4];
|
const sizePresets = [0.25, 0.3333, 0.5, 1, 2, 3, 4];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Should we allow the user to select hqx? Chrome currently has a wasm bug, so we currently avoid it
|
||||||
|
* there, unless overridden.
|
||||||
|
* crbug.com/974804
|
||||||
|
*/
|
||||||
|
const allowHqx: boolean = (() => {
|
||||||
|
const url = new URL(location.href);
|
||||||
|
return url.searchParams.has('allow-hqx')
|
||||||
|
// Yep. UA sniffing. Let's hope we can remove this soon.
|
||||||
|
// Block browsers with Chrome/, unless they also have Edge/ (since the Edge UA includes Chrome/)
|
||||||
|
|| !navigator.userAgent.includes('Chrome/') || navigator.userAgent.includes('Edge/');
|
||||||
|
})();
|
||||||
|
|
||||||
export default class ResizerOptions extends Component<Props, State> {
|
export default class ResizerOptions extends Component<Props, State> {
|
||||||
state: State = {
|
state: State = {
|
||||||
maintainAspect: true,
|
maintainAspect: true,
|
||||||
@@ -150,7 +163,7 @@ export default class ResizerOptions extends Component<Props, State> {
|
|||||||
<option value="mitchell">Mitchell</option>
|
<option value="mitchell">Mitchell</option>
|
||||||
<option value="catrom">Catmull-Rom</option>
|
<option value="catrom">Catmull-Rom</option>
|
||||||
<option value="triangle">Triangle (bilinear)</option>
|
<option value="triangle">Triangle (bilinear)</option>
|
||||||
<option value="hqx">hqx (pixel art)</option>
|
{allowHqx && <option value="hqx">hqx (pixel art)</option>}
|
||||||
<option value="browser-pixelated">Browser pixelated</option>
|
<option value="browser-pixelated">Browser pixelated</option>
|
||||||
<option value="browser-low">Browser low quality</option>
|
<option value="browser-low">Browser low quality</option>
|
||||||
<option value="browser-medium">Browser medium quality</option>
|
<option value="browser-medium">Browser medium quality</option>
|
||||||
|
|||||||
Reference in New Issue
Block a user