Code Monkey home page Code Monkey logo

jpeg-recompress-bin's Introduction

jpeg-recompress-bin GitHub Actions Status

Compress JPEGs by re-encoding to the smallest JPEG quality while keeping perceived visual quality the same and by making sure huffman tables are optimized

You probably want imagemin-jpeg-recompress instead.

Install

$ npm install --save jpeg-recompress-bin

Usage

import {execFile} from 'node:child_process';
import jpegRecompress from 'jpeg-recompress-bin';

execFile(jpegRecompress, ['--quality high', '--min 60', 'input.jpg', 'output.jpg'], error => {
	console.log('Image minified');
});

CLI

$ npm install --global jpeg-recompress-bin
$ jpeg-recompress --help

License

MIT © Imagemin

jpeg-recompress-bin's People

Contributors

1000ch avatar kevva avatar samdaltonmaag avatar shinnn avatar sindresorhus avatar timdp 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

jpeg-recompress-bin's Issues

Installation fails in `node:14-alpine` Docker image

How to reproduce:

$ docker run -t --rm --entrypoint yarn node:14-alpine global add jpeg-recompress-bin
yarn global v1.22.4
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
error /usr/local/share/.config/yarn/global/node_modules/jpeg-recompress-bin: Command failed.
Exit code: 1
Command: node lib/install.js
Arguments: 
Directory: /usr/local/share/.config/yarn/global/node_modules/jpeg-recompress-bin
Output:
⚠ spawn /usr/local/share/.config/yarn/global/node_modules/jpeg-recompress-bin/vendor/jpeg-recompress ENOENT
  ⚠ jpeg-recompress pre-build test failed
info Visit https://yarnpkg.com/en/docs/cli/global for documentation about this command.

Inside the container:

/usr/src/app # /usr/local/share/.config/yarn/global/node_modules/jpeg-recompress-bin/vendor/jpeg-recompress 
/bin/sh: /usr/local/share/.config/yarn/global/node_modules/jpeg-recompress-bin/vendor/jpeg-recompress: not found

/usr/src/app # file /usr/local/share/.config/yarn/global/node_modules/jpeg-recompress-bin/vendor/jpeg-recompre
ss 
/usr/local/share/.config/yarn/global/node_modules/jpeg-recompress-bin/vendor/jpeg-recompress: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.24, BuildID[sha1]=6fe1a43ed9bf9ace7ff3b95d2e0c3d8ab98ef3d8, not stripped

/usr/src/app # ldd /usr/local/share/.config/yarn/global/node_modules/jpeg-recompress-bin/vendor/jpeg-recompres
s 
	/lib64/ld-linux-x86-64.so.2 (0x7f797940d000)
	libm.so.6 => /lib64/ld-linux-x86-64.so.2 (0x7f797940d000)
	libc.so.6 => /lib64/ld-linux-x86-64.so.2 (0x7f797940d000)
Error relocating /usr/local/share/.config/yarn/global/node_modules/jpeg-recompress-bin/vendor/jpeg-recompress: __vfprintf_chk: symbol not found
Error relocating /usr/local/share/.config/yarn/global/node_modules/jpeg-recompress-bin/vendor/jpeg-recompress: __printf_chk: symbol not found
Error relocating /usr/local/share/.config/yarn/global/node_modules/jpeg-recompress-bin/vendor/jpeg-recompress: __fprintf_chk: symbol not found
Error relocating /usr/local/share/.config/yarn/global/node_modules/jpeg-recompress-bin/vendor/jpeg-recompress: __sprintf_chk: symbol not found

fs.exists fails on Windows

In index.js, there's a check for the jpeg-recompress binary. However, on Windows, the file is called jpeg-recompress.exe. The script subsequently tries to compile it from source, which fails because the build environment isn't set up.

file isn't output on aborting

hello. i use gulp-image package, that has jpeg-recompress-bin inside it.
i'm facing the next problem:

[16:48:48] Command failed: D:\b_media\node_modules\jpeg-recompress-bin\vendor\jpeg-recompress.exe --strip --min 95 C:\Users\gosteev\AppData\Local\Temp\d8188d00-21ba-42b7-a480-455718a8178f C:\Users\gosteev\AppData\Local\Temp\30f922a0-68ae-4fca-a0be-d953f6bf826a
ssim at q=95 (95 - 95): 0.999987
ssim at q=95 (95 - 94): 0.999987
ssim at q=95 (95 - 94): 0.999987
ssim at q=95 (95 - 94): 0.999987
ssim at q=95 (95 - 94): 0.999987
Final optimized ssim at q=95: 0.999975
New size is 113% of original (saved 0 kb)
Output file is larger than input, aborting!

when output file is larger, no file outputs. seems like that is something similar.
how can i make non-optimized files to continue piping?
Thanks

`GLIBC_2.14' not found (Debian 7.6)

I get the following when running the example page from the readme:

 /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.14' not found (required by /home/vagrant/node_modules/jpeg-recompress-bin/vendor/jpeg-recompress)

The output of running libc.so.6:

GNU C Library (Debian EGLIBC 2.13-38+deb7u3) stable release version 2.13

Using the latest version of libc6 from apt-get. Is it the case that I can't use it with my version of Debian?

facing issue while installing using docker

I am getting below error while building docker image of app "https://github.com/DX26-io/flair-notifications" on ubuntu 18.04.
npm ERR! command failed
npm ERR! command sh -c node lib/install.js
npm ERR! connect ETIMEDOUT 49.44.79.236:443
npm ERR! jpeg-recompress pre-build test failed

npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2023-05-25T14_19_19_767Z-debug-0.log

jpeglib.h not found

I have followed your directions, yet I still get this error when I try to install:

> [email protected] postinstall /usr/local/lib/node_modules/jpeg-recompress-bin
> node ./lib/build.js

  1.0.1.tar.gz: downloading [===================] 100% 0.0s


✗ Command failed: In file included from src/util.c:1:
src/util.h:9:10: fatal error: 'jpeglib.h' file not found
#include <jpeglib.h>
         ^
1 error generated.
make: *** [src/util.o] Error 1

[email protected] /usr/local/lib/node_modules/jpeg-recompress-bin
├── [email protected] ([email protected], [email protected], [email protected])
└── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected])

I've installed libjpeg via homebrew, and it does exist in /usr/local/include/. Not sure how to avoid this error.

Build on windows fail

Hi,

[email protected] postinstall C:\Program Files\nodejs\node_modules\jpeg-recompress-bin
node lib/install.js

internal/child_process.js:298
throw errnoException(err, 'spawn');
^

Error: spawn UNKNOWN
at exports._errnoException (util.js:837:11)
at ChildProcess.spawn (internal/child_process.js:298:11)
at exports.spawn (child_process.js:339:9)
at C:\Users\user\AppData\Roaming\nvm\v4.1.1\node_modules\jpeg-recompress-bin\node_modules\bin-check\index.j
s:22:12
at C:\Users\user\AppData\Roaming\nvm\v4.1.1\node_modules\jpeg-recompress-bin\node_modules\executable\index.
js:27:4
at FSReqWrap.oncomplete (fs.js:82:15)
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli
.js" "install" "--global" "jpeg-recompress-bin"
npm ERR! node v4.1.1
npm ERR! npm v3.4.0
npm ERR! code ELIFECYCLE

npm ERR! [email protected] postinstall: node lib/install.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] postinstall script 'node lib/install.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the jpeg-recompress-bin package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node lib/install.js
npm ERR! You can get their info via:
npm ERR! npm owner ls jpeg-recompress-bin
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR! D:\wamp\www\report\npm-debug.log

Unrecognized flag error

No matter what I do I'm getting the following error using the code from your README verbatim:

{ Error: Command failed: /Users/jasonogasian/projects/dasher-tools/node_modules/jpeg-recompress-bin/vendor/jpeg-recompress --quality high --min 60 uploads/b0eb905b7d5d1fee9218191048ff7e46 uploads/b0eb905b7d5d1fee9218191048ff7e46_compressed
unrecognized flag --quality high

at ChildProcess.exithandler (child_process.js:211:12)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:191:7)
at maybeClose (internal/child_process.js:885:16)
at Socket.<anonymous> (internal/child_process.js:334:11)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at Pipe._handle.close [as _onclose] (net.js:501:12)

killed: false,
code: 1,
signal: null,
cmd: '/Users/jasonogasian/projects/dasher-tools/node_modules/jpeg-recompress-bin/vendor/jpeg-recompress --quality high --min 60 uploads/b0eb905b7d5d1fee9218191048ff7e46 uploads/b0eb905b7d5d1fee9218191048ff7e46_compressed' }`

Enable building on Linux if starting fails

This package does not work on aarch64 linux. Suggestions:

  • add aarch64 binary
  • remove build check for linux (why is it there?):
 	if (process.platform === 'win32' || process.platform === 'linux') {
		// eslint-disable-next-line unicorn/no-process-exit
		process.exit(1);
	}

Command name mistake.

In package.json, the name of the command is declared as jpeg-recomress, in which a 'p' is missing. I hope you can fix it.

Can't pass install this package in docker linux

I make it works well on my local with OSX but can't deploy it to docker kubernetes with linux
Here is error

[5/5] Building fresh packages...
error /app/node_modules/jpeg-recompress-bin: Command failed.
Exit code: 1
Command: node lib/install.js
Arguments:
Directory: /app/node_modules/jpeg-recompress-bin
Output:
⚠ spawn /app/node_modules/jpeg-recompress-bin/vendor/jpeg-recompress ENOENT
⚠ jpeg-recompress pre-build test failed

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.