Commit a8d54c65 authored by rockyl's avatar rockyl

init

parents
Pipeline #193909 failed with stages
in 0 seconds
root = true
[*]
indent_style = tab
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.yml]
indent_style = space
indent_size = 2
* text=auto eol=lf
node_modules
vendor/pngquant*
vendor/share*
yarn.lock
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="PROJECT" charset="UTF-8" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JavaScriptSettings">
<option name="languageLevel" value="ES6" />
</component>
<component name="PhpWorkspaceProjectConfiguration" backward_compatibility_performed="true" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" />
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/pngquant-bin.iml" filepath="$PROJECT_DIR$/.idea/pngquant-bin.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectFrameBounds" extendedState="6">
<option name="x" value="1680" />
<option name="y" value="23" />
<option name="width" value="1920" />
<option name="height" value="1107" />
</component>
<component name="PropertiesComponent">
<property name="SHARE_PROJECT_CONFIGURATION_FILES" value="true" />
<property name="WebServerToolWindowFactoryState" value="true" />
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
<property name="nodejs_interpreter_path.stuck_in_default_project" value="/usr/local/bin/node" />
<property name="nodejs_npm_path_reset_for_default_project" value="true" />
</component>
<component name="RunManager">
<configuration default="true" type="JUnit" factoryName="JUnit">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
<module name="" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
<option name="PACKAGE_NAME" />
<option name="MAIN_CLASS_NAME" />
<option name="METHOD_NAME" />
<option name="TEST_OBJECT" value="class" />
<option name="VM_PARAMETERS" value="-ea" />
<option name="PARAMETERS" />
<option name="WORKING_DIRECTORY" value="$MODULE_DIR$" />
<option name="ENV_VARIABLES" />
<option name="PASS_PARENT_ENVS" value="true" />
<option name="TEST_SEARCH_SCOPE">
<value defaultName="singleModule" />
</option>
<envs />
<patterns />
<method />
</configuration>
<configuration default="true" type="TestNG" factoryName="TestNG">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
<module name="" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
<option name="SUITE_NAME" />
<option name="PACKAGE_NAME" />
<option name="MAIN_CLASS_NAME" />
<option name="METHOD_NAME" />
<option name="GROUP_NAME" />
<option name="TEST_OBJECT" value="CLASS" />
<option name="VM_PARAMETERS" value="-ea" />
<option name="PARAMETERS" />
<option name="WORKING_DIRECTORY" value="$MODULE_DIR$" />
<option name="OUTPUT_DIRECTORY" />
<option name="ANNOTATION_TYPE" />
<option name="ENV_VARIABLES" />
<option name="PASS_PARENT_ENVS" value="true" />
<option name="TEST_SEARCH_SCOPE">
<value defaultName="singleModule" />
</option>
<option name="USE_DEFAULT_REPORTERS" value="false" />
<option name="PROPERTIES_FILE" />
<envs />
<properties />
<listeners />
<method />
</configuration>
<configuration default="true" type="Applet">
<option name="POLICY_FILE" value="$APPLICATION_HOME_DIR$/bin/appletviewer.policy" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<configuration default="true" type="Application" factoryName="Application">
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<configuration default="true" type="#org.jetbrains.idea.devkit.run.PluginConfigurationType">
<module name="" />
<option name="VM_PARAMETERS" value="-Xmx512m -Xms256m -XX:MaxPermSize=250m -ea" />
<option name="PROGRAM_PARAMETERS" />
<predefined_log_file enabled="true" id="idea.log" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>
<component name="masterDetails">
<states>
<state key="ProjectJDKs.UI">
<settings>
<last-edited>1.8</last-edited>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
</states>
</component>
</project>
\ No newline at end of file
package-lock=false
language: node_js
node_js:
- '10'
- '8'
- '6'
addons:
apt:
packages:
- libpng-dev
- zlib1g-dev
#!/usr/bin/env node
'use strict';
const execa = require('execa');
const m = require('.');
execa(m, process.argv.slice(2), {stdio: 'inherit'});
'use strict';
module.exports = require('./lib').path();
'use strict';
const path = require('path');
const BinWrapper = require('bin-wrapper');
const pkg = require('../package.json');
const url = `https://raw.githubusercontent.com/imagemin/pngquant-bin/v${pkg.version}/vendor/`;
module.exports = new BinWrapper()
.src(`${url}macos/pngquant`, 'darwin')
.src(`${url}linux/x86/pngquant`, 'linux', 'x86')
.src(`${url}linux/x64/pngquant`, 'linux', 'x64')
.src(`${url}freebsd/x64/pngquant`, 'freebsd', 'x64')
.src(`${url}win/pngquant.exe`, 'win32')
.dest(path.resolve(__dirname, '../vendor'))
.use(process.platform === 'win32' ? 'pngquant.exe' : 'pngquant');
'use strict';
const path = require('path');
const binBuild = require('bin-build');
const log = require('logalot');
const bin = require('.');
bin.run(['--version']).then(() => {
log.success('pngquant pre-build test passed successfully');
}).catch(err => {
log.warn(err.message);
log.warn('pngquant pre-build test failed');
log.info('compiling from source');
const libpng = process.platform === 'darwin' ? 'libpng' : 'libpng-dev';
binBuild.file(path.resolve(__dirname, '../vendor/source/pngquant.tar.gz'), [
'rm ./INSTALL',
`./configure --prefix="${bin.dest()}"`,
`make install BINPREFIX="${bin.dest()}"`
]).then(() => {
log.success('pngquant built successfully');
}).catch(err => {
err.message = `pngquant failed to build, make sure that ${libpng} is installed`;
log.error(err.stack);
// eslint-disable-next-line unicorn/no-process-exit
process.exit(1);
});
});
MIT License
Copyright (c) Imagemin (github.com/imagemin)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
{
"name": "pngquant-bin",
"version": "5.0.2",
"description": "`pngquant` wrapper that makes it seamlessly available as a local dependency",
"license": "MIT",
"repository": "imagemin/pngquant-bin",
"author": {
"name": "Kevin Mårtensson",
"email": "kevinmartensson@gmail.com",
"url": "github.com/kevva"
},
"maintainers": [
{
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
{
"name": "Shinnosuke Watanabe",
"url": "github.com/shinnn"
}
],
"bin": {
"pngquant": "cli.js"
},
"engines": {
"node": ">=6"
},
"scripts": {
"postinstall": "node lib/install.js",
"test": "xo && ava"
},
"files": [
"cli.js",
"index.js",
"lib",
"vendor/source"
],
"keywords": [
"imagemin",
"compress",
"image",
"img",
"minify",
"optimize",
"png",
"pngquant"
],
"dependencies": {
"bin-build": "^3.0.0",
"bin-wrapper": "^4.0.1",
"execa": "^0.10.0",
"logalot": "^2.0.0"
},
"devDependencies": {
"ava": "*",
"bin-check": "^4.0.1",
"compare-size": "^3.0.0",
"tempy": "^0.2.1",
"xo": "*"
}
}
# pngquant-bin [![Build Status](https://travis-ci.org/imagemin/pngquant-bin.svg?branch=master)](https://travis-ci.org/imagemin/pngquant-bin)
> [`pngquant`](https://github.com/pornel/pngquant) is a PNG compressor that significantly reduces file sizes by converting images to a more efficient 8-bit PNG format
You probably want [`imagemin-pngquant`](https://github.com/imagemin/imagemin-pngquant) instead.
## Install
```
$ npm install pngquant-bin
```
## Usage
```js
const execFile = require('child_process').execFile;
const pngquant = require('pngquant-bin');
execFile(pngquant, ['-o', 'output.png', 'input.png'], err => {
console.log('Image minified!');
});
```
## CLI
```
$ npm install --global pngquant-bin
```
```
$ pngquant --help
```
## Updating pre-compiled binaries
The Linux binaries are statically linked so they should work on all Linux distributions. To recompile them:
1. `sudo apt-get install libpng-dev`
2. `./configure CFLAGS=-static && make && cp pngquant pngquant-64`
3. Repeat the above commands, but in a 32-bin docker container started with: docker run -ti -v `pwd`:/source i386/debian:9.3 bash
## License
MIT © [Imagemin](https://github.com/imagemin)
import fs from 'fs';
import path from 'path';
import test from 'ava';
import execa from 'execa';
import tempy from 'tempy';
import binCheck from 'bin-check';
import binBuild from 'bin-build';
import compareSize from 'compare-size';
import m from '.';
test('rebuild the pngquant binaries', async t => {
const tmp = tempy.directory();
await binBuild.file(path.resolve(__dirname, 'vendor/source/pngquant.tar.gz'), [
'rm ./INSTALL',
`./configure --prefix="${tmp}"`,
`make install BINPREFIX="${tmp}"`
]);
t.true(fs.existsSync(path.join(tmp, 'pngquant')));
});
test('verify binary', async t => {
t.true(await binCheck(m, ['--version']));
});
test('minify a png', async t => {
const tmp = tempy.directory();
const src = path.join(__dirname, 'fixtures/test.png');
const dest = path.join(tmp, 'test.png');
const args = [
'-o',
dest,
src
];
await execa(m, args);
const res = await compareSize(src, dest);
t.true(res[dest] < res[src]);
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment