Giter Club home page Giter Club logo

mozjpeg-bin's Introduction

mozjpeg-bin GitHub Actions Status

mozjpeg is a production-quality JPEG encoder that improves compression while maintaining compatibility with the vast majority of deployed decoders

You probably want imagemin-mozjpeg instead.

Install

$ npm install mozjpeg

Usage

import {execFile} from 'node:child_process';
import mozjpeg from 'mozjpeg';

execFile(mozjpeg, ['-outfile', 'output.jpg', 'input.jpg'], err => {
	console.log('Image minified!');
});

CLI

$ npm install --global mozjpeg
$ mozjpeg --help

License

MIT © Imagemin

mozjpeg-bin's People

Contributors

1000ch avatar ackar avatar brentbrownfield avatar farcop avatar frantisekz avatar jorrit avatar kevva avatar mateuszkrawczuk avatar michel-kraemer avatar rejas avatar shinnn avatar sindresorhus avatar tomaszkrzyzanowski avatar tuananh avatar valpackett avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mozjpeg-bin's Issues

OSX: "pre-build test failed, compiling from source"

$ npm i mozjpeg

...

> [email protected] postinstall /Users/deepsweet/.../node_modules/mozjpeg
> node lib/install.js

⚠ pre-build test failed, compiling from source...
✖ { [Error: Command failed: autoreconf: Entering directory `.'
autoreconf: configure.ac: not using Gettext
autoreconf: running: aclocal --force
autoreconf: configure.ac: tracing
autoreconf: running: glibtoolize --copy --force
autoreconf: running: /usr/local/Cellar/autoconf/2.69/bin/autoconf --force
autoreconf: running: /usr/local/Cellar/autoconf/2.69/bin/autoheader --force
autoreconf: running: automake --add-missing --copy --force-missing
configure.ac:23: installing './ar-lib'
configure.ac:18: installing './compile'
configure.ac:24: installing './config.guess'
configure.ac:24: installing './config.sub'
configure.ac:8: installing './install-sh'
configure.ac:8: installing './missing'
Makefile.am: installing './depcomp'
autoreconf: Leaving directory `.'
configure: error: installation or configuration problem: assembler cannot create object files.
] killed: false, code: 1, signal: null }
[email protected] node_modules/mozjpeg
├── [email protected] ([email protected])
├── [email protected] ([email protected], [email protected], [email protected])
└── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])
$ autoreconf --version

autoreconf (GNU Autoconf) 2.69
...
$ sw_vers

ProductName:    Mac OS X
ProductVersion: 10.10
BuildVersion:   14A388b

EventEmitter memory leak detected!

[email protected] postinstall /var/www/doniai/production/source/node_modules/mozjpeg
node lib/install.js

(node:30091) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 SIGINT listeners added to [process]. Use emitter.setMaxListeners() to increase limit
✔ mozjpeg pre-build test passed successfully

not working

var mozjpeg = require('mozjpeg');
//gulp mozjpeg

gulp.task('mozjpeg', function() {
    return execFile(mozjpeg, ['-outfile', 'build/img/', 'src/img/**/*.jpg'], function (err) {
    console.log('Image minified!');
});
});

Build script issue

mozilla/mozjpeg#346

After upgrading mozjpeg, compressing some JPEG images fails with error:

Command failed: [...]/mozjpeg/vendor/cjpeg -quality 95 -maxmemory 4096
Backing store not supported

installation fails on OS X

OS X 10.11.5
Xcode Version 7.3.1
Node v6.2.0

npm i mozjpeg-bin
npm WARN deprecated [email protected]: graceful-fs v3.0.0 and before will fail on node releases >= v7.0. Please update to graceful-fs@^4.0.0 as soon as possible. Use 'npm ls graceful-fs' to find it in the tree.

> [email protected] postinstall /Users/me/project/node_modules/mozjpeg-bin
> node postinstall.js

Building mozjpeg...
(node:2942) fs: re-evaluating native module sources is not supported. If you are using the graceful-fs module, please update it to a more recent version.
✗ Error: Command failed: autoreconf -fiv && ./configure --prefix="/Users/me/project/node_modules/mozjpeg-bin/bin" --bindir="/Users/me/project/node_modules/mozjpeg-bin/bin" --libdir="/Users/me/project/node_modules/mozjpeg-bin/bin" && make install
/bin/sh: autoreconf: command not found

Install error in OSX Yosemite

I personally cannot replicate, but 4 students have reported the same issue:

 ✖ Error: autoreconf -fiv && ./configure --disable-shared --prefix="/Users/JustinLoffredo/Documents/WWW/nycda-react-flux-art-challenge/node_modules/mozjpeg/vendor" --bindir="/Users/JustinLoffredo/Documents/WWW/nycda-react-flux-art-challenge/node_modules/mozjpeg/vendor" --libdir="/Users/JustinLoffredo/Documents/WWW/nycda-react-flux-art-challenge/node_modules/mozjpeg/vendor" && make --jobs=4 && make install --jobs=4
Command failed: ./configure --disable-shared --prefix="/Users/JustinLoffredo/Documents/WWW/nycda-react-flux-art-challenge/node_modules/mozjpeg/vendor" --bindir="/Users/JustinLoffredo/Documents/WWW/nycda-react-flux-art-challenge/node_modules/mozjpeg/vendor" --libdir="/Users/JustinLoffredo/Documents/WWW/nycda-react-flux-art-challenge/node_modules/mozjpeg/vendor"

./configure: line 13758: syntax error near unexpected token `libpng,'
./configure: line 13758: `PKG_CHECK_MODULES(libpng, libpng, HAVE_LIBPNG=1,'

I initially had to have them install libtool and autoconf to get the install running, but I can't get past this issue. A syntax error seems pretty strange.

Resolve dependency on logsalot related to CVE-2021-33623

I created a similar issue upstream in the imagemin-mozjpeg project.

At issue is the dependency in this package upon what appears to be an abandoned project (logsalot) contributed by @kevva. It looks like it should be reasonably trivial to switch to a different package to generate the logs. https://www.npmjs.com/package/better-logging may be a contender.

Thanks for your consideration about how best to resolve this so as to address CVE-2021-33623.

FYI: when beeing installed, doesn't make vendor folder

after installation, I got the error;
node_modules/mozjpeg-stream/node_modules/mozjpeg/vendor/cjpeg ENOENT

I had to manually call the install.js file
node node_modules/mozjpeg-stream/node_modules/mozjpeg/lib/install.js

after that, mozjpeg can be used.

Thought I'd let the community know..

Bad gateway when Github is having operational problems

Not sure if there's any way to avoid relying on Github being operational, but I'm getting this when trying to install this package now:

‼ Response code 502 (Gateway Error)
‼ mozjpeg pre-build test failed
i compiling from source
× HTTPError: Response code 502 (Bad Gateway)

mozjpeg build horribly slowing down the mobile CI

As part of our iOS and Android builds for a hybrid mobile application built using JS, HTML5 and CSS, we are using npm install to install our dependencies. One of the dependency "ionic-minify" through a series of dependencies and transitive dependencies calls "[email protected] install which then calls:

[email protected] postinstall //node_modules/mozjpeg
node lib/install.js

This step takes forever (almost 30-40 minutes) to finish on a Mac Mini where we are running a ci server to automatically build iOS and Android mobile packages. I have tried increasing the verbose level of npm log in an attempt to find the source of the problem but unfortunately the logging verbosity level only applies to the direct dependencies specified in my application packages.json and does not provide verbose logging information when the first level dependencies do "npm install" on their dependencies as part of the build of our application.

Please help.

mozjpeg preinstall failed

when I install mozjpeg globally and mozjepg --help, I got this error.
Environment: Ubuntu 22.04.1 LTS
Node version: 14.20.0

Here is the command I tried.

npm -g install mozjpeg
npm WARN deprecated [email protected]: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
/home/gf/.nvm/versions/node/v14.20.0/bin/mozjpeg -> /home/gf/.nvm/versions/node/v14.20.0/lib/node_modules/mozjpeg/cli.js

> [email protected] postinstall /home/gf/.nvm/versions/node/v14.20.0/lib/node_modules/mozjpeg
> node lib/install.js

+ [email protected]
added 163 packages from 52 contributors in 49.827s
mozjpeg --help

events.js:377
      throw er; // Unhandled 'error' event
      ^

Error: spawn /home/gf/.nvm/versions/node/v14.20.0/lib/node_modules/mozjpeg/vendor/cjpeg ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:277:19)
    at onErrorNT (internal/child_process.js:472:16)
    at processTicksAndRejections (internal/process/task_queues.js:82:21)
Emitted 'error' event on ChildProcess instance at:
    at Process.ChildProcess._handle.onexit (internal/child_process.js:283:12)
    at onErrorNT (internal/child_process.js:472:16)
    at processTicksAndRejections (internal/process/task_queues.js:82:21) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'spawn /home/gf/.nvm/versions/node/v14.20.0/lib/node_modules/mozjpeg/vendor/cjpeg',
  path: '/home/gf/.nvm/versions/node/v14.20.0/lib/node_modules/mozjpeg/vendor/cjpeg',
  spawnargs: [ '--help' ]
}

Actually when post install, I don't get any error or message.
Also I have installed all packages automake autoconf libtool dpkg pkgconfig nasm libpng

Is there anyone faced this issue?

Thanks.

Support for `Internal Network`

Some people cannot download sources by public network.
So the next url cannot be reached https://github.com/mozilla/mozjpeg/releases/download/v3.1/mozjpeg-3.1-release-source.tar.gz.

Please put it in npm source or make it configurable in ENV such as export IMAGEMIN_MOZJPEG_SOURCE=https://github.com/mozilla/mozjpeg/releases/download/v3.1/mozjpeg-3.1-release-source.tar.gz

The same problem with pngquant-bin, gifsicle-bin, optipng-bin, ...

Please!

Bump `bin-wrapper` to latest stable package

Hey guys,

could you upgrade the bin-wrapper dependency as I suspect it's causing the ansi-regex package to be outdated to an unstable version causing a high CVE in my project when scanning with trivy.

Installation of mozjpeg fails

Console Output

rahul@googly ~/work/deep_impact/rupert $ npm install mozjpeg
[email protected] /Users/rahul/work/deep_impact/rupert
├── [email protected]
├─┬ [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected]
│ └── [email protected]
└── [email protected]

npm WARN [email protected] No license field.
npm ERR! Darwin 15.4.0
npm ERR! argv "/usr/local/Cellar/node5/5.11.1/bin/node" "/usr/local/bin/npm" "install" "mozjpeg"
npm ERR! node v5.11.1
npm ERR! npm  v3.8.6
npm ERR! path /Users/rahul/work/deep_impact/rupert/node_modules/mozjpeg/cli.js
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall chmod

npm ERR! enoent ENOENT: no such file or directory, chmod '/Users/rahul/work/deep_impact/rupert/node_modules/mozjpeg/cli.js'
npm ERR! enoent ENOENT: no such file or directory, chmod '/Users/rahul/work/deep_impact/rupert/node_modules/mozjpeg/cli.js'
npm ERR! enoent This is most likely not a problem with npm itself
npm ERR! enoent and is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/rahul/work/deep_impact/rupert/npm-debug.log

Log File: npm-debug.txt

Request to remove gulp-util using the following API replacements

gutil.File => https://www.npmjs.com/package/vinyl
gutil.replaceExtension => The .extname property on Vinyl objects or https://www.npmjs.com/package/replace-ext
gutil.colors => https://www.npmjs.com/package/ansi-colors
gutil.date => https://www.npmjs.com/package/date-format
gutil.log => https://www.npmjs.com/package/fancy-log
gutil.template => https://www.npmjs.com/package/lodash.template
gutil.env => https://www.npmjs.com/package/minimist
gutil.beep => https://www.npmjs.com/package/beeper
gutil.noop => https://www.npmjs.com/package/through2
gutil.isStream => Use the .isStream() method on Vinyl objects
gutil.isBuffer => Use the .isBuffer() method on Vinyl objects
gutil.isNull => Use the .isNull() method on Vinyl objects
gutil.linefeed => Use the string '\n' in your code
gutil.combine => https://www.npmjs.com/package/multipipe
gutil.buffer => https://www.npmjs.com/package/list-stream
gutil.PluginError => https://www.npmjs.com/package/plugin-error

mozjpeg pre-build test failed, and "autoreconf -fiv"

image
As shown, I'm about to install a library called Lodash, but it throw error: Command failed: C:\Windows\system32\cmd.exe /s /c "autoreconf -fiv"
'autoreconf' is not recognized as an internal or external command,
operable program or batch file.

I have no idea about it, Can someone help me?

[email protected] fails to build binary at postinstall

[email protected]
[email protected]
Ubuntu 14.04.5 LTS

$ npm i mozjpeg

> [email protected] postinstall /home/aandrosov/node_modules/mozjpeg
> node lib/install.js

  ⚠ The `/home/aandrosov/node_modules/mozjpeg/vendor/cjpeg` binary doesn't seem to work correctly
  ⚠ mozjpeg pre-build test failed
  ℹ compiling from source
  ✖ Error: autoreconf -fiv && ./configure --disable-shared --disable-dependency-tracking --with-jpeg8  --prefix="/home/aandrosov/node_modules/mozjpeg/vendor" --bindir="/home/aandrosov/node_modules/mozjpeg/vendor" --libdir="/home/aandrosov/node_modules/mozjpeg/vendor" && make -j4 && make install -j4
Command failed: autoreconf -fiv
autoreconf: Entering directory `.'
autoreconf: configure.ac: not using Gettext
autoreconf: running: aclocal --force 
autoreconf: configure.ac: tracing
autoreconf: configure.ac: not using Libtool
autoreconf: running: /usr/bin/autoconf --force
configure.ac:23: error: possibly undefined macro: AC_PROG_LIBTOOL
      If this token and others are legitimate, please use m4_pattern_allow.
      See the Autoconf documentation.
autoreconf: /usr/bin/autoconf failed with exit status: 1

    at ChildProcess.exithandler (child_process.js:275:12)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at maybeClose (internal/child_process.js:925:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)

mozjpeg not support on centos 7

I tried to install mozjpeg on centos 7 via npm install mozjpeg -g, the installation is successfully, but the binary could not run.

[root@localhost lib64]# mozjpeg --version
/usr/lib/node_modules/mozjpeg/vendor/cjpeg: /lib64/libz.so.1: version `ZLIB_1.2.9' not found (required by /usr/lib/node_modules/mozjpeg/vendor/cjpeg)
[root@localhost lib64]# ldd /usr/lib/node_modules/mozjpeg/vendor/cjpeg
/usr/lib/node_modules/mozjpeg/vendor/cjpeg: /lib64/libz.so.1: version `ZLIB_1.2.9' not found (required by /usr/lib/node_modules/mozjpeg/vendor/cjpeg)
	linux-vdso.so.1 =>  (0x00007ffc035fd000)
	libz.so.1 => /lib64/libz.so.1 (0x00007f5b6d993000)
	libm.so.6 => /lib64/libm.so.6 (0x00007f5b6d691000)
	libc.so.6 => /lib64/libc.so.6 (0x00007f5b6d2c3000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f5b6dba9000)
[root@localhost lib64]# ll /lib64/libz.so*
lrwxrwxrwx. 1 root root    13 Nov 21 16:52 /lib64/libz.so -> libz.so.1.2.7
lrwxrwxrwx. 1 root root    13 Feb 16 10:49 /lib64/libz.so.1 -> libz.so.1.2.7
-rwxr-xr-x. 1 root root 90160 May 12  2022 /lib64/libz.so.1.2.7
[root@localhost lib64]# cat /etc/os-release 
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"

CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"

[root@localhost lib64]#

Trying to install mozjpeg - behind corporate network

hello,

i'm trying to install gatsby using a default template, which requires mozjpeg. however, i'm getting this error:

C:\dev>npm i -g mozjpeg
C:\Users\a\AppData\Roaming\npm\mozjpeg -> C:\Users\a\AppData\Roaming\npm\node_modules\mozjpeg\cli.js
`> [email protected] postinstall C:\Users\a\AppData\Roaming\npm\node_modules\mozjpeg` `> node lib/install.js`
(node:13428) Warning: Setting the NODE_TLS_REJECT_UNAUTHORIZED environment variable to '0' makes TLS connections and HTTPS requests insecure by disabling certificate verification.
‼ self signed certificate in certificate chain
‼ mozjpeg pre-build test failed
i compiling from source
× RequestError: self signed certificate in certificate chain
at ClientRequest.<anonymous> (C:\Users\a\AppData\Roaming\npm\node_modules\mozjpeg\node_modules\got\index.js:111:21)
at Object.onceWrapper (events.js:284:20)
at ClientRequest.emit (events.js:196:13)
at TLSSocket.socketErrorListener (_http_client.js:402:9)
at TLSSocket.emit (events.js:196:13)
at emitErrorNT (internal/streams/destroy.js:91:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:59:3)
at processTicksAndRejections (internal/process/task_queues.js:84:17)
+ [email protected]
updated 1 package in 13.251s

I've already set strict-ssl and NODE_TLS_REJECT_UNAUTHORIZED to false, but can't seem to get around this issue.

hopefully someone can help?

tks
Lawrence

its not worked

Please make sure that your environment has nasm, zlib, and automake if macOS.

# for macOS
brew install automake nasm zlib

# for Ubuntu
sudo apt-get install nasm zlib1g-dev

Originally posted by @1000ch in #67 (comment)

npm install error 7.1.1

[node  4/21] RUN npm install
npm notice 
npm notice New major version of npm available! 7.4.3 -> 8.0.0
npm notice Changelog: <https://github.com/npm/cli/releases/tag/v8.0.0>
npm notice Run `npm install -g [email protected]` to update!``
npm notice 
npm ERR! code 1
npm ERR! path /src/node_modules/mozjpeg
npm ERR! command failed
npm ERR! command sh -c node lib/install.js
npm ERR! compiling from source
npm ERR! Command failed: /src/node_modules/mozjpeg/vendor/cjpeg -version
npm ERR! /src/node_modules/mozjpeg/vendor/cjpeg: /lib/x86_64-linux-gnu/libz.so.1: version 'ZLIB_1.2.9' not found 
(required by /src/node_modules/mozjpeg/vendor/cjpeg)
npm ERR! 
npm ERR! 
**npm ERR! mozjpeg pre-build test failed**
npm ERR! Error: Command failed: /bin/sh -c ./configure --enable-static --disable-shared --disable-dependency-
tracking --with-jpeg8  --prefix="/src/node_modules/mozjpeg/vendor" --bindir="/src/node_modules/mozjpeg/vendor" --libdir="/src/node_modules/mozjpeg/vendor"
npm ERR! configure: error: no nasm (Netwide Assembler) found

Since your last change in the test file in version 7.1.1 our Build process has stopped working.
We have fixed it by locking the version to the previous one.

I am commenting this in case anyone else has this problem until it is fixed.

Installation fails on Ubuntu 16.10 amd64

Module build failed: Error: /home/oleg/projects/main-panel/node_modules/mozjpeg/vendor/cjpeg: error while loading shared libraries: libpng12.so.0: cannot open shared object file: No such file or directory

I fixed it by installing libpng12 but it is not true way.

Release new version to npm

@1000ch Could you update current library version and release it? It would be great. I'm preparing patches to mattermost app to support arm64 and updated version of mozjpeg-bin is also needed to fix some building issue.

Not working in node:alpine Docker base image

I've got an app that relies on mozjpeg-bin the following way:

import imagemin from "imagemin";
import imageminMozjpeg from "imagemin-mozjpeg";

// ...

await imagemin(["/path/to/my/file.jpg"], "/output-path", {
  plugins: [imageminMozjpeg({ quality: 42 })],
});

Things work locally on macOS and in Docker, when an image is based on node:10.15.3 (Debian). However, when I switch to node:10.15.3-alpine, the following error shows up for each attempt to optimize an image:

Error in file: /path/to/my/file.jpg

spawn /app/node_modules/mozjpeg/vendor/cjpeg ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:240:19)
    at onErrorNT (internal/child_process.js:415:16)
    at process._tickCallback (internal/process/next_tick.js:63:19)

I tried a few workaround including installing libjpeg-turbo and libjpeg-turbo-utils packages and even tried some crazy things like swapping the binary in node_modules/mozjpeg/vendor/cjpeg, but no result after hours of hacking. The only solution was to switch back to Debian at a cost of a large added container size.

What can be done to make mozjpeg work in Alpine? Happy to switch back, but unfortunately can't manage this myself.

Can't build on raspberry pi.

I am building a project on my raspberry pi (model 4b) with react-boilerplate@v4 which requires this project as a dependency. But I got an error on yarn install.

Then I try to create an empty node project and add only this project, it also reproduces this error:

The error file is attached:
yarn-error.log

P.S. the raspberry pi is running raspbian v10. wich ARMv7 cpu arch.

Remove gulp-util

remove gulp-util using the following API replacements:

gutil.File => https://www.npmjs.com/package/vinyl
gutil.replaceExtension => The .extname property on Vinyl objects or https://www.npmjs.com/package/replace-ext
gutil.colors => https://www.npmjs.com/package/ansi-colors
gutil.date => https://www.npmjs.com/package/date-format
gutil.log => https://www.npmjs.com/package/fancy-log
gutil.template => https://www.npmjs.com/package/lodash.template
gutil.env => https://www.npmjs.com/package/minimist
gutil.beep => https://www.npmjs.com/package/beeper
gutil.noop => https://www.npmjs.com/package/through2
gutil.isStream => Use the .isStream() method on Vinyl objects
gutil.isBuffer => Use the .isBuffer() method on Vinyl objects
gutil.isNull => Use the .isNull() method on Vinyl objects
gutil.linefeed => Use the string '\n' in your code
gutil.combine => https://www.npmjs.com/package/multipipe
gutil.buffer => https://www.npmjs.com/package/list-stream
gutil.PluginError => https://www.npmjs.com/package/plugin-error

Mozjpeg 3.2 is out

It includes :

  • updated libjpeg-turbo (v1.5.0)
  • Fixed interaction of JINT_DC_SCAN_OPT_MODE and JBOOLEAN_OPTIMIZE_SCANS
  • #define JPEG_C_PARAM_SUPPORTED 1 for easier interoperability with stock libjpeg
  • Minor bugfixes in yuvjpeg/jpegyuv test helper tools

Moreover it could be a nice opportunity to fix OSX installation failure.
Thanks

Apple Silicon M1 builds fail with incorrect path to libpng libraries

I'm reporting an issue on an M1 without Rosetta 2.

Environment:

  • Node version: v16.4.0
  • MacOS version: 11.4
  • libpng version: 1.6.37

Reproduce issue:

First, without installing a number of pre-requisites I get the following after running yarn add imagemin-mozjpeg in an empty project:

error /Users/rgillson/Desktop/Projects/Repos/Private/Web/test/node_modules/mozjpeg: Command failed.
Exit code: 1
Command: node lib/install.js
Arguments:
Directory: /Users/rgillson/Desktop/Projects/Repos/Private/Web/test/node_modules/mozjpeg
Output:
⚠ spawn Unknown system error -86
  ⚠ mozjpeg pre-build test failed
  ℹ compiling from source
  ✖ Error: Command failed: /bin/sh -c autoreconf -fiv
/bin/sh: autoreconf: command not found


    at /Users/rgillson/Desktop/Projects/Repos/Private/Web/test/node_modules/bin-build/node_modules/execa/index.js:231:11

After running brew install automake autoconf libtool m4 nasm libpng pkg-config and attempting again, yarnpkg now exits with:

error /Users/rgillson/Desktop/Projects/Repos/Personal/Private/Web/test/node_modules/mozjpeg: Command failed.
Exit code: 1
Command: node lib/install.js
Arguments:
Directory: /Users/rgillson/Desktop/Projects/Repos/Personal/Private/Web/test/node_modules/mozjpeg
Output:
⚠ spawn Unknown system error -86
  ⚠ mozjpeg pre-build test failed
  ℹ compiling from source
  ✖ Error: Command failed: /bin/sh -c make -j8
clang: error: no such file or directory: '/usr/local/lib/libpng16.a'
make[2]: *** [cjpeg] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2

/Library/Developer/CommandLineTools/usr/bin/make  all-recursive
Making all in java
echo timestamp > classnoinst.stamp
Making all in simd
  GEN      jsimdcfg.inc
/Library/Developer/CommandLineTools/usr/bin/make  all-am
  CC       libsimd_la-jsimd_arm64.lo
  CPPAS    jsimd_arm64_neon.lo
  CCLD     libsimd.la
Making all in md5
  CC       md5cmp-md5cmp.o
  CC       md5cmp-md5.o
  CC       md5cmp-md5hl.o
  CCLD     md5cmp
  CC       cjpeg-cdjpeg.o
  CC       cjpeg-cjpeg.o
  CC       cjpeg-rdgif.o
  CC       cjpeg-rdtarga.o
  CC       cjpeg-rdbmp.o
  CC       cjpeg-rdjpeg.o
  CC       cjpeg-rdppm.o
  CC       cjpeg-rdswitch.o
  CC       cjpeg-rdpng.o
  CC       jcapimin.lo
  CC       jcapistd.lo
  CC       jccoefct.lo
  CC       jccolor.lo
  CC       jcdctmgr.lo
  CC       jcext.lo
  CC       jchuff.lo
  CC       jcinit.lo
  CC       jcmainct.lo
  CC       jcmarker.lo
  CC       jcmaster.lo
  CC       jcomapi.lo
  CC       jcparam.lo
  CC       jcphuff.lo
  CC       jcprepct.lo
  CC       jcsample.lo
  CC       jctrans.lo
  CC       jdapimin.lo
  CC       jdapistd.lo
  CC       jdatadst.lo
  CC       jdatasrc.lo
  CC       jdcoefct.lo
  CC       jdcolor.lo
  CC       jddctmgr.lo
  CC       jdhuff.lo
  CC       jdinput.lo
  CC       jdmainct.lo
  CC       jdmarker.lo
  CC       jdmaster.lo
  CC       jdmerge.lo
  CC       jdphuff.lo
  CC       jdpostct.lo
  CC       jdsample.lo
  CC       jdtrans.lo
  CC       jerror.lo
  CC       jfdctflt.lo
  CC       jfdctfst.lo
  CC       jfdctint.lo
  CC       jidctflt.lo
  CC       jidctfst.lo
  CC       jidctint.lo
  CC       jidctred.lo
  CC       jquant1.lo
  CC       jquant2.lo
  CC       jutils.lo
  CC       jmemmgr.lo
  CC       jmemnobs.lo
  CC       jaricom.lo
  CC       jcarith.lo
  CC       jdarith.lo
  CC       djpeg-cdjpeg.o
  CC       djpeg-djpeg.o
  CC       djpeg-rdcolmap.o
  CC       djpeg-rdswitch.o
  CC       djpeg-wrgif.o
  CC       djpeg-wrppm.o
  CC       djpeg-wrbmp.o
  CC       djpeg-wrtarga.o
  CC       jpegtran.o
  CC       rdswitch.o
  CC       cdjpeg.o
  CC       transupp.o
  CC       rdjpgcom.o
  CC       wrjpgcom.o
  CC       tjbench-tjbench.o
  CC       tjbench-bmp.o
  CC       tjbench-tjutil.o
  CC       tjbench-rdbmp.o
  CC       tjbench-rdppm.o
  CC       tjbench-wrbmp.o
  CC       tjbench-wrppm.o
  CC       libturbojpeg_la-jcapimin.lo
  CC       libturbojpeg_la-jcapistd.lo
  CC       libturbojpeg_la-jccoefct.lo
  CC       libturbojpeg_la-jccolor.lo
  CC       libturbojpeg_la-jcdctmgr.lo
  CC       libturbojpeg_la-jcext.lo
  CC       libturbojpeg_la-jchuff.lo
  CC       libturbojpeg_la-jcinit.lo
  CC       libturbojpeg_la-jcmainct.lo
  CC       libturbojpeg_la-jcmarker.lo
  CC       libturbojpeg_la-jcmaster.lo
  CC       libturbojpeg_la-jcomapi.lo
  CC       libturbojpeg_la-jcparam.lo
  CC       libturbojpeg_la-jcphuff.lo
  CC       libturbojpeg_la-jcprepct.lo
  CC       libturbojpeg_la-jcsample.lo
  CC       libturbojpeg_la-jctrans.lo
  CC       libturbojpeg_la-jdapimin.lo
  CC       libturbojpeg_la-jdapistd.lo
  CC       libturbojpeg_la-jdatadst.lo
  CC       libturbojpeg_la-jdatasrc.lo
  CC       libturbojpeg_la-jdcoefct.lo
  CC       libturbojpeg_la-jdcolor.lo
  CC       libturbojpeg_la-jddctmgr.lo
  CC       libturbojpeg_la-jdhuff.lo
  CC       libturbojpeg_la-jdinput.lo
  CC       libturbojpeg_la-jdmainct.lo
  CC       libturbojpeg_la-jdmarker.lo
  CC       libturbojpeg_la-jdmaster.lo
  CC       libturbojpeg_la-jdmerge.lo
  CC       libturbojpeg_la-jdphuff.lo
  CC       libturbojpeg_la-jdpostct.lo
  CC       libturbojpeg_la-jdsample.lo
  CC       libturbojpeg_la-jdtrans.lo
  CC       libturbojpeg_la-jerror.lo
  CC       libturbojpeg_la-jfdctflt.lo
  CC       libturbojpeg_la-jfdctfst.lo
  CC       libturbojpeg_la-jfdctint.lo
  CC       libturbojpeg_la-jidctflt.lo
  CC       libturbojpeg_la-jidctfst.lo
  CC       libturbojpeg_la-jidctint.lo
  CC       libturbojpeg_la-jidctred.lo
  CC       libturbojpeg_la-jquant1.lo
  CC       libturbojpeg_la-jquant2.lo
  CC       libturbojpeg_la-jutils.lo
  CC       libturbojpeg_la-jmemmgr.lo
  CC       libturbojpeg_la-jmemnobs.lo
  CC       libturbojpeg_la-jaricom.lo
  CC       libturbojpeg_la-jcarith.lo
  CC       libturbojpeg_la-jdarith.lo
  CC       libturbojpeg_la-turbojpeg.lo
  CC       libturbojpeg_la-transupp.lo
  CC       libturbojpeg_la-jdatadst-tj.lo
  CC       libturbojpeg_la-jdatasrc-tj.lo
  CC       jcstest.o
  CC       jpegyuv.o
  CC       yuvjpeg.o
  CC       tjunittest.o
  CC       tjutil.o
  CCLD     libjpeg.la
  CCLD     libturbojpeg.la
  CCLD     cjpeg
  CCLD     djpeg
  CCLD     jpegtran
  CCLD     rdjpgcom
  CCLD     wrjpgcom
  CCLD     jpegyuv
  CCLD     jcstest
  CCLD     yuvjpeg

    at /Users/rgillson/Desktop/Projects/Repos/Personal/Private/Web/test/node_modules/execa/index.js:231:11
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Promise.all (index 0)
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

Finally, I have confirmed the library is symlinked at /opt/homebrew/lib/libpng16.a to /opt/homebrew/Cellar/libpng/1.6.37/lib/libpng16.a.

cfgExtras = 'libpng_LIBS=\'/usr/local/lib/libpng16.a -lz\' --enable-static';

It seems the location is hardcoded based on previous install location of libpng before Homebrew moved everything under /opt/homebrew. I think a more futureproof implementation of the build would be to find where the relevant libraries are installed rather than depending on them being in a specific location.

Workaround

For now, it was enough to: sudo ln -s /opt/homebrew/Cellar/libpng/1.6.37/lib/libpng16.a libpng16.a which resulted in a successful package install

Please help in compressing image using mozjpeg Node JS Package

Here is the code that I am trying to run:

  var execFile = require('child_process').execFile;
  var mozjpeg = require("mozjpeg")

  execFile(mozjpeg, ['-outfile', './output.jpg', 'http://www.barth.com/hires/N10_JB07006.jpg'], function (err) {
    if(err){
      console.log("Error in mozjpeg: "+JSON.stringify(err, null,4));
    }
    else{
      console.log('Image minified! without error');
    }
  });

Below is the error that I get:

Error in mozjpeg: {
"killed": false,
"code": 1,
"signal": null,
"cmd": "/home/ec2-user/ec2apps/curieAppBackend/node_modules/mozjpeg/vendor/cjpeg -outfile ./output.jpg http://www.barth.com/hires/N10_JB07006.jpg"
}

Could some one please suggest:

  • How I could resolve this error ?
  • Where is the output.jpg (compressed / minified) file stored / located.

Self signed certificate in chain problems

Hi,
i am getting this error while trying to install mozjpeg:
src\Frontend\node_modules\mozjpeg

node lib/install.js

‼ self signed certificate in certificate chain
‼ mozjpeg pre-build test failed
i compiling from source
x RequestError: self signed certificate in certificate chain
at ClientRequest. (c:\Users\pa_suja\Documents\norgesportalen\EpiS
erver\src\Frontend\node_modules\got\index.js:74:21)
at ClientRequest.g (events.js:291:16)
at emitOne (events.js:96:13)
at ClientRequest.emit (events.js:188:7)
at TLSSocket.socketErrorListener (_http_client.js:310:9)
at emitOne (events.js:96:13)
at TLSSocket.emit (events.js:188:7)
at emitErrorNT (net.js:1278:8)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickCallback (internal/process/next_tick.js:98:9)
npm WARN [email protected] No repository field.

Any suggestions?

Please add environment variable to set bin download URL

like node-sass can set sass-binary-site to download bin library.

function getBinaryUrl() {
  var site = getArgument('--sass-binary-site') ||
             process.env.SASS_BINARY_SITE  ||
             process.env.npm_config_sass_binary_site ||
             (pkg.nodeSassConfig && pkg.nodeSassConfig.binarySite) ||
             'https://github.com/sass/node-sass/releases/download';

  return [site, 'v' + pkg.version, getBinaryName()].join('/');
}

For some reason in china download from github is very slow.

We usually install package from https://npm.taobao.org/mirrors

pngquant-bin: https://npm.taobao.org/mirrors/pngquant-bin/
mozjpeg-bin: https://npm.taobao.org/mirrors/mozjpeg-bin/
cwebp-bin: https://npm.taobao.org/mirrors/cwebp-bin/

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.