Coder Social home page Coder Social logo

jpegoptim-bin's Introduction

imagemin

Minify images seamlessly





Install

npm install imagemin

Usage

import imagemin from 'imagemin';
import imageminJpegtran from 'imagemin-jpegtran';
import imageminPngquant from 'imagemin-pngquant';

const files = await imagemin(['images/*.{jpg,png}'], {
	destination: 'build/images',
	plugins: [
		imageminJpegtran(),
		imageminPngquant({
			quality: [0.6, 0.8]
		})
	]
});

console.log(files);
//=> [{data: <Uint8Array 89 50 4e …>, destinationPath: 'build/images/foo.jpg'}, …]

API

imagemin(input, options?)

Returns Promise<object[]> in the format {data: Uint8Array, sourcePath: string, destinationPath: string}.

input

Type: string[]

File paths or glob patterns.

options

Type: object

destination

Type: string

Set the destination folder to where your files will be written. If no destination is specified, no files will be written.

plugins

Type: Array

The plugins to use.

glob

Type: boolean
Default: true

Enable globbing when matching file paths.

imagemin.buffer(data, options?)

Returns Promise<Uint8Array>.

data

Type: Uint8Array

The image data to optimize.

options

Type: object

plugins

Type: Array

Plugins to use.

Related

jpegoptim-bin's People

Contributors

1000ch avatar kevva avatar philipbordallo avatar shaneog avatar shinnn avatar sindresorhus avatar vikas5914 avatar xhmikosr 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

jpegoptim-bin's Issues

Statically link libjpeg(-turbo?)

Trying to run imagemin-jpegoptim on AWS Lambda:

/var/task/node_modules/jpegoptim-bin/vendor/jpegoptim: error while loading shared libraries: libjpeg.so.8: cannot open shared object file: No such file or directory

There is no system libjpeg… Maybe it should be linked statically?

FreeBSD installation fails

Hi,

we'd like to use your package on FreeBSD but have run into some trouble.

We do have the binary on our server already but unfortunately your install script (lib/install.js) doesn't check for that. Instead it tries to install the binary again but can't because the path for libjpeg doesn't work with this command:
".cmd('./configure --prefix="${bin.dest()}" --bindir="${bin.dest()}"')"

Is it possible to either check if the binary is already installed on the server and actually use that or maybe add the binary for FreeBSD?

Best regards,
Tia

Need Linux binary to v1.4.3 commit on a release

Can you please create a new release which includes these changes that are already on master. I depend on a package, imagemin-jpegoptim, that requires package and it is set to use ^3.0.0, but with that version your binary isn't at 1.4.3, its at 1.4.1 and I need it to be 1.4.3. If you were to create another release it would solve my problems, thanks!

Linux binary is still v1.4.1

I just installed on a Ubuntu 14.04 machine, and the Linux binary still seems to be version 1.4.1

ubuntu@test-server:~$ sudo npm install jpegoptim-bin --global
/usr/bin/jpegoptim -> /usr/lib/node_modules/jpegoptim-bin/cli.js

> [email protected] postinstall /usr/lib/node_modules/jpegoptim-bin
> node lib/install.js

  ✔ jpegoptim pre-build test passed successfully
[email protected] /usr/lib/node_modules/jpegoptim-bin
├── [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], [email protected], [email protected], [email protected], [email protected])
ubuntu@test-server:~$ jpegoptim --version
jpegoptim v1.4.1  x86_64-unknown-linux-gnu
Copyright (c) 1996-2014  Timo Kokkonen.

libjpeg version: 8d  15-Jan-2012
Copyright (C) 1991-2012 Thomas G. Lane, Guido Vollbeding
Copyright (C) 1999-2006 MIYASAKA Masaru
Copyright (C) 2009 Pierre Ossman for Cendio AB
Copyright (C) 2009-2013 D. R. Commander
Copyright (C) 2009-2011 Nokia Corporation and/or its subsidiary(-ies)
ubuntu@test-server:~$ md5sum /usr/bin/jpegoptim 
d4039c6c53d14dc03413679a5147ff91  /usr/bin/jpegoptim

Binaries “doesn’t seem to work correctly”

It appears something is wrong with the precompiled binaries, and they can’t be compiled from source either.

OS X El Capitan (10.11.2)
node v5.5.0
npm 3.3.12

GNU Make 3.81, built for i386-apple-darwin11.3.0

⚠ The `/Users/Tim/***/node_modules/jpegoptim-bin/vendor/jpegoptim` binary doesn't seem to work correctly
⚠ jpegoptim pre-build test failed
ℹ compiling from source
✖ Error: ./configure --prefix="/Users/Tim/***/node_modules/jpegoptim-bin/vendor" --bindir="/Users/Tim/***/node_modules/jpegoptim-bin/vendor" && make install
Command failed: /bin/sh -c ./configure --prefix="/Users/Tim/***/node_modules/jpegoptim-bin/vendor" --bindir="/Users/Tim/***/node_modules/jpegoptim-bin/vendor"

Let me know if you need additional information.

Update binaries

Older binaries doesn't support --stdin and --stdout options.

Error for shared server

It seems there is an error while installing. Contrary to other npm modules, this assumes one has access to root folder

I simply did

npm install --global jpegtran-bin

capturar

error in use jpegoptim-bin in node docker

hello i have a error when rebuilding all package :

yarn install v1.22.5
[1/4] Resolving packages...
[2/4] Fetching packages...
warning [email protected]: Invalid bin field for "mini-css-extract-plugin".
info [email protected]: The platform "linux" is incompatible with this module.
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
info [email protected]: The platform "linux" is incompatible with this module.
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
warning " > [email protected]" has unmet peer dependency "webpack@2 || 3 || 4".
warning " > [email protected]" has unmet peer dependency "webpack@^2.0.0 || ^3.0.0 || ^4.0.0".
warning " > [email protected]" has unmet peer dependency "css-loader@*".
[4/4] Building fresh packages...
[1/10] ⠈ advpng-bin
[8/10] ⠁ pngcrush-bin
[7/10] ⠁ optipng-bin
[4/10] ⠁ jpegoptim-bin
error /app/node_modules/jpegoptim-bin: Command failed.
Exit code: 1
Command: node lib/install.js
Arguments: 
Directory: /app/node_modules/jpegoptim-bin
Output:
⚠ spawn /app/node_modules/jpegoptim-bin/vendor/jpegoptim ENOENT
  ⚠ jpegoptim pre-build test failed
  ℹ compiling from source
  ✖ Error: Command failed: /bin/sh -c ./configure --prefix="/app/node_modules/jpegoptim-bin/vendor" --bindir="/app/node_modules/jpegoptim-bin/vendor"
configure: error: in `/tmp/fb44196e-45de-4dbf-a9dd-f6b0583d39ce':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details

checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking for gcc... no
checking for cc... no
checking for cl.exe... no



Doesn't work on new Apple M1 chip

Hello. I have an error when install package. How can I use it on Apple Silicone?

yarn add v1.22.10
info No lockfile found.
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
[4/4] 🔨  Building fresh packages...
error /Users/denis/Projects/Jpegoptim/node_modules/jpegoptim-bin: Command failed.
Exit code: 1
Command: node lib/install.js
Arguments: 
Directory: /Users/denis/Projects/Jpegoptim/node_modules/jpegoptim-bin
Output:
⚠ Command failed: /Users/denis/Projects/Jpegoptim/node_modules/jpegoptim-bin/vendor/jpegoptim --version
dyld: Library not loaded: /usr/local/opt/jpeg/lib/libjpeg.9.dylib
  Referenced from: /Users/denis/Projects/Jpegoptim/node_modules/jpegoptim-bin/vendor/jpegoptim
  Reason: no suitable image found.  Did find:
	/usr/local/opt/jpeg/lib/libjpeg.9.dylib: mach-o, but wrong architecture
	/opt/homebrew/Cellar/jpeg/9d/lib/libjpeg.9.dylib: mach-o, but wrong architecture


  ⚠ jpegoptim pre-build test failed
  ℹ compiling from source
  ✖ Error: Command failed: /bin/sh -c ./configure --prefix="/Users/denis/Projects/Jpegoptim/node_modules/jpegoptim-bin/vendor" --bindir="/Users/denis/Projects/Jpegoptim/node_modules/jpegoptim-bin/vendor"

checking build system type... arm-apple-darwin20.3.0
checking host system type... arm-apple-darwin20.3.0
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for a BSD-compatible install... /usr/bin/install -c
checking whether make sets $(MAKE)... yes
checking for jpeg_read_header in -ljpeg... no
Cannot find libjpeg or you have too old version (v6 or later required).

    at /Users/denis/Projects/Jpegoptim/node_modules/execa/index.js:231:11
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async Promise.all (index 0)
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

Cannot build on CentOS 7

Hi,

I have tried installing jpegoptim-bin on three different Digital Ocean droplets running CentOS 7 (x64). I get the same error on all three.

> [email protected] postinstall /home/tcbeer/node_modules/jpegoptim-bin
> node lib/install.js

  ⚠ The `jpegoptim` binary doesn't seem to work correctly
  ⚠ jpegoptim pre-build test failed
  ℹ compiling from source
  ✖ Error: ./configure --prefix="/home/tcbeer/node_modules/jpegoptim-bin/vendor" --bindir="/home/tcbeer/node_modules/jpegoptim-bin/vendor" && make install && mv /home/tcbeer/node_modules/jpegoptim-bin/vendor/bin/jpegoptim /home/tcbeer/node_modules/jpegoptim-bin/vendor/jpegoptim
Command failed: 
    at ChildProcess.exithandler (child_process.js:648:15)
    at ChildProcess.emit (events.js:98:17)
    at maybeClose (child_process.js:756:16)
    at Process.ChildProcess._handle.onexit (child_process.js:823:5)

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.