ysugimoto / aws-lambda-image

Automatic image resize/reduce on AWS Lambda
MIT License
823 stars 220 forks source link

write EPIPE error #199

Open biztrology-kd opened 4 years ago

biztrology-kd commented 4 years ago

{ "errorType": "Error", "errorMessage": "write EPIPE", "trace": [ "Error: write EPIPE", " at WriteWrap.afterWrite [as oncomplete] (net.js:789:14)" ] }

my image is 12M have this error,

schmoove commented 4 years ago

I would recommend doing a full install with the new 10.x runtime and dedicated layer.

Had a number of issues with this today, and a full reinstall got it working for me.

glassdimlygr commented 4 years ago

I installed from scratch and the latest and I'm getting this error for pngs and jpgs with this config, images are around 400KB. gifs work fine:

{
    "bucket": "mybucket",
    "backup": {
        "directory": "./original"
    },
    "keepExtension": true,
    "reduce": {
        "directory": "./reduced",
        "quality": 70,
        "acl": "public-read"
    },
    "optimizers": {
        "pngquant": ["--speed=1", "--quality=60-90"],
        "mozjpeg": ["-optimize", "-progressive", "-quality 70"],
        "gifsicle": ["-O3"]
    }
}
glassdimlygr commented 4 years ago

My issue here was the following line: "mozjpeg": ["-optimize", "-progressive", "-quality 70"], Specifically, "-quality 70". Likewise, "-quality=70" didn't work. This worked: "mozjpeg": ["-optimize", "-progressive"],

This seems a little odd to me seeing as I can test on my cli like so:

/usr/local/Cellar/mozjpeg/3.3.1_1/bin/cjpeg -optimize -progressive -quality 70  ./gorilla.jpg > gorilla-opt.jpg

But I guess quality is being set above in the reduce stanza, so perhaps that's why.

jshow commented 3 years ago

I'm seeing the same symptom. Using tagged v1.1(aws-lambda-image-with-dedicated-layer), replicable with any jpeg (4mb largest file). Occurs whenever a reduce config is provided. It feels like the binaries are not installed to reduce? When the reduce config is removed resizes work as expected

  "reduce": { 
    "directory": "downloads/",
    "suffix": "_sixty_percent",
    "quality":90
  },

I've experimented with different optimizer options (as recommended here) without a positive effect

  "optimizers": {
    "mozjpeg": ["-optimize", "-progressive"]
  },
  "jpegOptimizer": "jpegoptim",
  "optimizers": {
      "jpegoptim": ["--all-progressive"]
  },
jshow commented 3 years ago

I was able to solve short-term with the following config - changing the reduce into a resizes

"resizes": [
    {
      "directory": "downloads/",
      "suffix": "_sixty_percent",
      "size": "100%",
      "quality": 60
    },