elixir-waffle/waffle

transform in uploader only seems to work with jpg, not png

ProtoJazz opened this issue · 8 comments

Environment

  • Elixir version (elixir -v):
    Elixir 1.10.4 (compiled with Erlang/OTP 22)
  • Waffle version (mix deps):
    1.1.3
  • Operating system:
    Ubuntu

Expected behavior

Using transform I should be able to resize all images do different sizes

Actual behavior

Configuring a transform in my Uploader only seems to resize .jpg images, and just returns an uploaded .png image at full size.

  def transform(:thumb, _) do
     {:convert, "-strip -thumbnail 150x150^ -gravity center -extent 150x150 -format png", :png}
  end

Im not sure if I've done this wrong, or am missing some other config.
Running convert locally with the same params produces the right image, just not through a waffle upload.

The test passes, but when I use the same transform I get the same results as above

MyApp.Uploaders.ImageUploader.url({item.image, item}, :thumb, signed: true)

Seems to only resize jpg, and not png. I'm also using waffle_ecto, and waffle_gcs. So I'm not sure if the issues is configuration, or with some kind of interaction with the other stuff

Could this be an issue with file which you're trying to transform or with a library?

Could you, please, issue convert command directly in a terminal to check that the file and the library are working correctly and the issue is with Waffle?

Thank you

Using the convert command, same image, and same params does produce the right output in my local terminal. Though waffle it doesn't resize.

Hm, I'll look into it.

It would be helpful if you could try to replace png image which this test refers to in order to check will it still pass.

It does fail when I replace the image.png with one of the ones I was experiancing the issue with

.........................

  1) test transforms a file given as a binary (WaffleTest.Processor)
     test/processor_test.exs:109
     Assertion with == failed
     code:  assert "128x128" == geometry(@img)
     left:  "128x128"
     right: "651x676"
     stacktrace:
       test/processor_test.exs:121: (test)



  2) test transforms a copied version of file according to the specified transformation (WaffleTest.Processor)
     test/processor_test.exs:62
     Assertion with == failed
     code:  assert "128x128" == geometry(@img)
     left:  "128x128"
     right: "651x676"
     stacktrace:
       test/processor_test.exs:72: (test)

..

  3) test transforms a copied version of file according to a function transformation that returns a list (WaffleTest.Processor)
     test/processor_test.exs:94
     Assertion with == failed
     code:  assert "128x128" == geometry(@img)
     left:  "128x128"
     right: "651x676"
     stacktrace:
       test/processor_test.exs:104: (test)

..

  4) test transforms a copied version of file according to a function transformation that returns a string (WaffleTest.Processor)
     test/processor_test.exs:77
     Assertion with == failed
     code:  assert "128x128" == geometry(@img)
     left:  "128x128"
     right: "651x676"
     stacktrace:
       test/processor_test.exs:87: (test)

........

Finished in 4.0 seconds
55 tests, 4 failures, 14 excluded

Heres one of the test images I was using if it helps, I'll download it from this attachment and see if it still does it too. But I had the same issue a bunch of images and 2 different computers

Update: Yeah, downloading it from here it still fails in the tests

weirdmarge

Thanks for providing the image, I'll look into it.

Hi,

The test case is fine, image got resized.

In your example test fails because it asserts that original image is untouched but as you've changed an image, it'll have different size which is assert "651x676" == geometry(@img).

The next line asserts downsizing to 10x10 and passes correctly.