Skip to content

Commit

Permalink
Merge pull request #6 from stefansl/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
stefansl authored Feb 5, 2018
2 parents ac0ddad + 7842325 commit ac4f20f
Show file tree
Hide file tree
Showing 43 changed files with 3,863 additions and 140 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ node_modules
.idea
release-builds
.DS_Store
release
/.gitignore
/package-lock.json
build/
dist/
script.sh
/Mac_Distribution_Provisioning_Profiles_.provisionprofile
!/build/
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ Drag your image file onto the Image Shrinker window and it will saved in the sam
The original graphic will be not replaced.

## Download and Installation on MacOsX
Download Image Shrinker here:
https://github.com/stefansl/image-shrinker/releases/download/v1.2.0/Image.Shrinker.zip
Download Image Shrinker here:
https://github.com/stefansl/image-shrinker/releases/download/v1.2.1/Image%20Shrinker-1.2.1.dmg

Unpack and copy or drag the app into your MacOSX application folder.
For uninstalling, just drop the app into the bin.
Expand Down
11 changes: 10 additions & 1 deletion assets/css/imageshrinker.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion assets/css/imageshrinker.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 17 additions & 2 deletions assets/css/imageshrinker.scss
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ body {
#result {
max-height: 400px;
overflow-y: scroll;
-webkit-mask-image: -webkit-linear-gradient(bottom, transparent 1%, white 20%, white 90%,transparent 99%);
-webkit-mask-image: -webkit-linear-gradient(bottom, transparent 1%, white 20%, white 90%, transparent 99%);

}

Expand All @@ -120,12 +120,13 @@ body {

#menuSettings {
position: absolute;
z-index: 10;
padding: 3rem 1rem;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
background-color: rgba($black, .85);
background-color: rgba($black, .9);
color: rgba($white, .95);
transform: translate3d(-100%, 0, 0);
transition: transform 450ms cubic-bezier(0.23, 1, 0.32, 1);
Expand Down Expand Up @@ -154,6 +155,20 @@ body {
}
}

#btnOpenSettings {
z-index: 5;
&:hover {
color: rgba($black, .50);
}
}

#btnCloseSettings {
&:hover {
color: rgba($white, .75);
}

}

#btnOpenSettings, #btnCloseSettings {
position: absolute;
right: 1rem;
Expand Down
Binary file added assets/icons/mac/icon_image-shrinker.icns
Binary file not shown.
Binary file modified assets/icons/mac/icon_image-shrinker.svg.icns
Binary file not shown.
Binary file modified assets/icons/png/128x128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/png/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/icons/png/16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/png/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed assets/icons/png/24x24.png
Binary file not shown.
Binary file modified assets/icons/png/256x256.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/png/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/icons/png/32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/png/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed assets/icons/png/48x48.png
Binary file not shown.
Binary file modified assets/icons/png/512x512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/png/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed assets/icons/png/64x64.png
Binary file not shown.
Binary file removed assets/icons/png/96x96.png
Binary file not shown.
Binary file modified assets/img/screen.min.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/img/screen.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/128x128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/256x256.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/512x512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/[email protected]
Binary file added build/bg_dmg.png
Binary file added build/bg_dmg.tiff
Binary file not shown.
Binary file added build/[email protected]
Binary file added build/icon.icns
Binary file not shown.
Binary file added build/icon_dmg.icns
Binary file not shown.
6 changes: 2 additions & 4 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
<body>
<div class="wrapper">


<i class="icon icon-more-horiz icon-2x float-right" id="btnOpenSettings"></i>
<i class="icon icon-more-horiz icon-2x float-right d-block" id="btnOpenSettings"></i>

<section id="dragzone" class="">
<h1>Drag files here</h1>
Expand Down Expand Up @@ -45,7 +44,6 @@ <h3>Settings</h3>
</div>



<div class="columns">
<div class="column col-9">
Enable notifications
Expand Down Expand Up @@ -80,7 +78,7 @@ <h3>Settings</h3>
</a>
</div>

<i class="icon icon-cross icon-2x" id="btnCloseSettings"></i>
<i class="icon icon-cross icon-2x d-block" id="btnCloseSettings"></i>
</section>
</div>
<div id="background">
Expand Down
54 changes: 44 additions & 10 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const settings = require('electron-settings');
const execFile = require('child_process').execFile;
const mozjpeg = require('mozjpeg');
const pngquant = require('pngquant-bin');
const mkdirp = require('mkdirp');
// const console = require('console'); // only for dev

let svg = new svgo();
Expand Down Expand Up @@ -82,7 +83,7 @@ app.on('activate', () => {
ipcMain.on(
'shrinkImage', (event, fileName, filePath) => {

fs.readFile(filePath, 'utf8', function (err, data) {
fs.readFile(filePath, 'utf8', (err, data) => {

if (err) {
throw err;
Expand All @@ -95,8 +96,13 @@ ipcMain.on(
case '.svg':
svg.optimize(data)
.then(function (result) {
fs.writeFile(newFile, result.data, '', () => {});
event.sender.send('isShrinked', newFile);
fs.writeFile(newFile, result.data, (err) => {
if (!err) event.sender.send('isShrinked', newFile);
else dialog.showMessageBox({
'type': 'error',
'message': 'I\'m not able to write your new image. Sorry!'
});
});
})
.catch(function (error) {
dialog(error.message);
Expand All @@ -106,15 +112,23 @@ ipcMain.on(

case '.jpg':
case '.jpeg':
execFile(mozjpeg, ['-outfile', newFile, filePath], () => {
event.sender.send('isShrinked', newFile);
execFile(mozjpeg, ['-outfile', newFile, filePath], (err) => {
if (!err) event.sender.send('isShrinked', newFile);
else dialog.showMessageBox({
'type': 'error',
'message': 'I\'m not able to write your new image. Sorry!'
});
});

break;

case '.png':
execFile(pngquant, ['-o', newFile, filePath], () => {
event.sender.send('isShrinked', newFile);
execFile(pngquant, ['-fo', newFile, filePath], (err) => {
if (!err) event.sender.send('isShrinked', newFile);
else dialog.showMessageBox({
'type': 'error',
'message': 'I\'m not able to write your new image. Sorry!'
});
});

break;
Expand All @@ -130,12 +144,21 @@ ipcMain.on(
);


const generateNewPath = pathName => {
const generateNewPath = (pathName) => {

let fullpath = path.parse(pathName);

if(settings.get('folderswitch') === false && typeof settings.get('savepath') !== 'undefined') {
fullpath.dir = settings.get('savepath')[0];
if (settings.get('folderswitch') === false && typeof settings.get('savepath') !== 'undefined') {

let savepath = settings.get('savepath')[0];

if (!isDirSync(savepath)) {
mkdirp(savepath, function (err) {
if (err) console.error(err);
});
}

fullpath.dir = savepath;
}

fullpath.base = fullpath.name + '.min' + fullpath.ext;
Expand All @@ -144,4 +167,15 @@ const generateNewPath = pathName => {
};


// Check, if folder exists
const isDirSync = (aPath) => {
try {
return fs.statSync(aPath).isDirectory();
} catch (e) {
if (e.code === 'ENOENT') {
return false;
}
}
};

module.exports = debug;
Loading

0 comments on commit ac4f20f

Please sign in to comment.