Giter Club home page Giter Club logo

imagemin-app'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

imagemin-app's People

Contributors

danielruf avatar hhsnopek avatar kevva avatar sindresorhus 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

imagemin-app's Issues

Exception when run on Win10

I've downloaded the Windows zip of imagemin-app and extracted the contents to their own folder. When I run the exe on Win10 Pro (Creator's Edition) I get the below error message and after pressing ok a blank app window that allows no interaction except min/maximise and close.

imagemin_error

ENOENT error trying to build on windows

FYI, errors out using powershell due to touch command in the make file, might be worth noting in readme to use something like cygwin to get around that.

Error portion:

[email protected] node_modules\imagemin
├── [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], [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])
make[1]: Entering directory `C:/Users/devin/Documents/Repos/imagemin-app'
make[2]: Entering directory `C:/Users/devin/Documents/Repos/imagemin-app'
events.js:85
      throw er; // Unhandled 'error' event
            ^
Error: spawn C:\Users\devin\Documents\Repos\imagemin-app\node_modules\duo\node_modules\gnode\bin\gnode ENOENT
    at exports._errnoException (util.js:746:11)
    at Process.ChildProcess._handle.onexit (child_process.js:1053:32)
    at child_process.js:1144:20
    at process._tickCallback (node.js:355:11)
    at Function.Module.runMain (module.js:503:11)
    at startup (node.js:129:16)
    at node.js:814:3
make[2]: Leaving directory `C:/Users/devin/Documents/Repos/imagemin-app'
make[2]: Entering directory `C:/Users/devin/Documents/Repos/imagemin-app'
events.js:85
      throw er; // Unhandled 'error' event
            ^
Error: spawn C:\Users\devin\Documents\Repos\imagemin-app\node_modules\duo\node_modules\gnode\bin\gnode ENOENT
    at exports._errnoException (util.js:746:11)
    at Process.ChildProcess._handle.onexit (child_process.js:1053:32)
    at child_process.js:1144:20
    at process._tickCallback (node.js:355:11)
    at Function.Module.runMain (module.js:503:11)
    at startup (node.js:129:16)
    at node.js:814:3
make[2]: Leaving directory `C:/Users/devin/Documents/Repos/imagemin-app'
make[1]: Leaving directory `C:/Users/devin/Documents/Repos/imagemin-app'

Stuff that works (above error)


> [email protected] postinstall C:\Users\devin\Documents\Repos\imagemin-app\node_modules\imagemin\node_modules\imagemin-gifsicle\node_modules\gifsicle\node_modules\bin-wrapper\node_modules\bin-check\node_modules\spawn-sync
> node postinstall


> [email protected] postinstall C:\Users\devin\Documents\Repos\imagemin-app\node_modules\imagemin\node_modules\imagemin-optipng\node_modules\optipng-bin\node_modules\bin-wrapper\node_modules\bin-check\node_modules\spawn-sync
> node postinstall


> [email protected] postinstall C:\Users\devin\Documents\Repos\imagemin-app\node_modules\imagemin\node_modules\imagemin-pngquant\node_modules\pngquant-bin\node_modules\bin-wrapper\node_modules\bin-check\node_modules\spawn-sync
> node postinstall


> [email protected] postinstall C:\Users\devin\Documents\Repos\imagemin-app\node_modules\imagemin\node_modules\imagemin-jpegtran\node_modules\jpegtran-bin\node_modules\bin-wrapper\node_modules\bin-check\node_modules\spawn-sync
> node postinstall


> [email protected] postinstall C:\Users\devin\Documents\Repos\imagemin-app\node_modules\imagemin\node_modules\imagemin-jpegtran\node_modules\jpegtran-bin
> node lib/install.js

     fetch : https://raw.github.com/imagemin/jpegtran-bin/v1.0.2/vendor/win/x64/jpegtran.exe
     fetch : https://raw.github.com/imagemin/jpegtran-bin/v1.0.2/vendor/win/x64/libjpeg-62.dll




√ pre-build test passed successfully!

> [email protected] postinstall C:\Users\devin\Documents\Repos\imagemin-app\node_modules\imagemin\node_modules\imagemin-optipng\node_modules\optipng-bin
> node lib/install.js

     fetch : https://raw.github.com/imagemin/optipng-bin/v1.0.1/vendor/win/optipng.exe


√ pre-build test passed successfully!

> [email protected] postinstall C:\Users\devin\Documents\Repos\imagemin-app\node_modules\imagemin\node_modules\imagemin-pngquant\node_modules\pngquant-bin
> node lib/install.js

     fetch : https://raw.github.com/imagemin/pngquant-bin/v1.0.1/vendor/win/pngquant.exe


√ pre-build test passed successfully!

> [email protected] postinstall C:\Users\devin\Documents\Repos\imagemin-app\node_modules\imagemin\node_modules\imagemin-gifsicle\node_modules\gifsicle
> node lib/install.js

     fetch : https://raw.github.com/imagemin/gifsicle-bin/v1.0.3/vendor/win/x64/gifsicle.exe


√ pre-build test passed successfully!
[email protected] node_modules\object-assign

[email protected] node_modules\each-async
├── [email protected]
└── [email protected]

[email protected] node_modules\clean-css
└── [email protected]

[email protected] node_modules\uglify-js
├── [email protected]
├── [email protected]
├── [email protected] ([email protected], [email protected], [email protected], [email protected])
└── [email protected] ([email protected])

[email protected] node_modules\duo
├── [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] ([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] ([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] ([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], [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] node_modules\myth
├── [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])
├── [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])
└── [email protected] ([email protected], [email protected])

Installation on Ubuntu requires node-webkit workaround

node-webkit is build against libudev.so.0 , Ubuntu newer than 13.04 comes with libudev.so.1

therefore running make fails with the following message:

imagemin-app/node_modules/nodewebkit/nodewebkit/nw: error while loading shared libraries: libudev.so.0: cannot open shared object file: No such file or directory

Solutions can be found here:
https://github.com/rogerwang/node-webkit/wiki/The-solution-of-lacking-libudev.so.0

maybe there is an easy way to inclued a fix into the make process

Plugin inclusion

Any plans to include a few more plugins like webp or guetzli?

Windows Binary 'Path too long' error

There are several errors relating to 'Path too long' when attempting to extract the Windows Binary .zip file. I believe this is happening to more than one file. I am on Windows 10 64 bit.

Steps to reproduce:

  1. Download the Windows Binary.
  2. Extract the Windows Binary.
  3. Observe the errors.

image

Rename app

Is there a way to name the app something like Imagemin. Right now (on OSX, at least) it shows up as Atom

screen shot 2017-01-04 at 10 13 22 am

How to Build in Win7

Hi, first this is my first time to try electro, so pardon me :)

i've installed electron with npm install electron-prebuilt -g

but when i try to run make app, i've got error like this

$ make app
sh.exe": make: command not found

i can running electron from my console for info :)

any hint for me?

Thanks :)

Infinite loading in the app

I have drag and drop the .PNG file into the app and it's seems to be loading forever
image
last binary, MacOS 10.15.5

Pretty UI

The spinner is nice, but the rest is a bit bland.

Linux binary requires libpng12.so.0

I had to install libpng to be able to optimize png files on archlinux.
Log

~/imagemin-app-v0.1.0-linux/resources/app/node_modules/imagemin/node_modules/imagemin-pngquant/node_modules/pngquant-bin/vendor/pngquant: error while loading shared libraries: libpng12.so.0: cannot open shared object file: No such file or directory

Workaround - install it via aur https://aur.archlinux.org/packages/libpng12/

Imagemin app generate different result compare to imagemin itself

The result of Imagemin windows app is 33kb. but when I use js code to use imagemin directly output for same picture is 57kb.

I tried to copy exact same code as index.js but the result stays the same (57kb).

What am I missing here?

Here is my code:

const imagemin = require('imagemin');
const imageminGifsicle = require('imagemin-gifsicle');
const imageminJpegtran = require('imagemin-jpegtran');
const imageminOptipng = require('imagemin-optipng');
const imageminPngquant = require('imagemin-pngquant');
const imageminSvgo = require('imagemin-svgo');

(async () => {
	const files = await imagemin(['images/*.png'], {
		destination: 'build',
		use: [
			imageminGifsicle(),
			imageminJpegtran(),
			imageminOptipng(),
			imageminPngquant(),
			imageminSvgo()
		]
	});	
})();

Update: the optimized image using imagemin-cli also is 57kb. do you use some sort of black magic inside imagemin-app?

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.