imagemin / imagemin-pngquant

Imagemin plugin for `pngquant`
MIT License
316 stars 81 forks source link

error in electron build file #47

Closed justyeh closed 5 years ago

justyeh commented 6 years ago

i hava create an image compress tool base on electron , use imagemin-pngquant to compress png file , it is useful in electron develop mode,but there is an error when i build electron to a exe file ,

Error: Error in file: C:/Users/54657645/Desktop/images/5.png

    at exports._errnoException (util.js:1024)
    at Socket._writeGeneric (net.js:762)
    at Socket._write (net.js:781)
    at doWrite (_stream_writable.js:371)
    at writeOrBuffer (_stream_writable.js:357)
    at Socket.Writable.write (_stream_writable.js:274)
    at Socket.write (net.js:699)
    at Socket.Writable.end (_stream_writable.js:536)
    at Socket.end (net.js:491)
    at handleInput (C:\Users\54657645\AppData\Local\Programs\imagecompress\resources\app.asar\node_modules\imagemin-png…:89)
macisi commented 6 years ago

The imagemin plugin uses 'spawn' which does not support in asar package. You should use 'execFile' instead.

steveostudios commented 5 years ago

I'm running into this same issue. @macisi can you explain a little more of how you'd use execFile. The crazy thing is everything works in Development and Production on my machine, but fails every time on Windows.

Here is my code for imagemin:

imagemin(
        ["/path/to/folder/to/optimize],
        "/path/to/output/folder",
        {
          use: [imageminPngquant({ quality: "65-80" })]
        }
      )
.then(() => resolve(data))
.catch(err => reject(data))
macisi commented 5 years ago

I'm running into this same issue. @macisi can you explain a little more of how you'd use execFile. The crazy thing is everything works in Development and Production on my machine, but fails every time on Windows.

Here is my code for imagemin:

imagemin(
        ["/path/to/folder/to/optimize],
        "/path/to/output/folder",
        {
          use: [imageminPngquant({ quality: "65-80" })]
        }
      )
.then(() => resolve(data))
.catch(err => reject(data))

@steveostudios Here is my code, hopes it would help😄 https://github.com/EHDFE/ehdev-shell/blob/master/src/controller/tools/processors/pngquant.js#L8

sindresorhus commented 5 years ago

This is an issue with Electron and not Imagemin.

You can complain here: https://github.com/electron/electron/issues/9459