elixir-mogrify / mogrify

Image processing in Elixir (ImageMagick command line wrapper)
MIT License
569 stars 65 forks source link

1 jpg file failed with Mogrify.save() #119

Closed sc-yan closed 3 months ago

sc-yan commented 3 months ago

I know this is a very weird case, but I really appreciate if you could take a look.

so we found 1 specific image file always failed to be uploaded in our staging env. however, it succeeded in local and our production env, which is very weird. we run the same code in stg and prod, and I checked the library version, they are surprisingly same in local/stg/prod.

~ $ magick -version
Version: ImageMagick 7.1.1-32 Q16-HDRI x86_64 22207 https://imagemagick.org
Copyright: (C) 1999 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC HDRI Modules OpenMP(4.5)
Delegates (built-in): bzlib cairo fftw fontconfig freetype gslib heic jng jpeg jxl lcms ltdl lzma pangocairo png ps raw rsvg tiff webp x xml zlib zstd
Compiler: gcc (13.2)

the error stacktrack we got is this:

│ phoenix ** (exit) an exception was raised:
│ phoenix     ** (MatchError) no match of right hand side value: {"", 137}
│ phoenix         (mogrify 0.9.1) lib/mogrify.ex:43: Mogrify.save/2
│ phoenix         (ovice 0.1.0) lib/xxx/models/avatar.ex:109: xxx.Model.Avatar.upload_avatar/2

this is the code we are running.

%Mogrify.Image{path: avatar_path, ext: ""}
    |> Mogrify.resize("150x150")
    |> Mogrify.auto_orient()
    |> Mogrify.format("png")
    |> Mogrify.save(path:  output_file)

I suspect it's caused by magick lib, so I run the command against the picture. however, it also succeeded.. magick mogrify -resize 256x256 -format png -auto-orient dfvcx.jpg

this is the image file. dfvxc

I have no clue now. could you take a look please? or shall I ask this in magick lib repo? really appreciate your help! thank you.

talklittle commented 3 months ago

Exit code 137 sounds like out of memory or disk space.

Check this SO question for other possible causes (process timeout) if using Docker: https://stackoverflow.com/questions/59296801/docker-compose-exit-code-is-137-when-there-is-no-oom-exception

sc-yan commented 3 months ago

our elixir application is deployed in k8s and I increased the resources for the pod in staging env. it works!! this image takes particular longer time than other images when we call this API. it should ring a bell lol. again, thank you so much!!