question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

modifying Thumbor conf value on Mac OS X (RESPECT_ORIENTATION = True)

See original GitHub issue

I need to change the Thumbor to not rotate images by default by changing this config value RESPECT_ORIENTATION = True to avoid the case like the attached image (basically all landscape mobile photos)

(I’m befuddled why RESPECT_ORIENTATION is False by default? Why would we want Thumbor to rotate an source image w/out explicitly asking for it?)

I’m on Mac OS X (High Sierra) - checked out repo, set up Python w/ virtualenv, ran ./build-s3-dist.sh {{bucketname...actually doesn't matter}} and all compiled well locally - then I uploaded the generated file from dist/serverless-image-handler.zip into an s3 bucket (needed to do that rather than direct upload since > 50MB) and then uploaded from the associated Lamda.

Excited to see my images not rotated…but got an internal server error trying to render an image and looking at CloudWatch see the following:

Unable to import module 'image_handler/lambda_function': /var/task/PIL/_imaging.so: invalid ELF header

Almost sure this is b/c I’m compiling in an environment that (OS X) that doesn’t match that of the Lamda. (@arahayrabedian apparently had more luck: https://github.com/awslabs/serverless-image-handler/issues/11 - guessing he was on Linux?)

Any hints? Do I need to spin up an EC2 Linux or use Docker?

This is a lot of pain for a 1 line change! I wish Thumbor config files be adjusted from Lamda environment variables, but I believe they’re build time so not possible.

image

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:15 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
mattslycommented, Mar 30, 2018

Update - was able to finally get this to work - posting a summary overview here for anyone else who is on a Mac and wants to make changes to the default Thumbor config

  1. Check out this project
  2. Make the one line (or more) edits per above in source/image_handler/thumbor.conf file
  3. Download and install Docker: https://docs.docker.com/docker-for-mac/install/
  4. Follow this basic outline from blog post and leverage this set of AWS Lamda specific built docker images to create a docker container based on the Lamda Python 2.7 environment and mount the directory of this project: - docker run -v <directory with this project>:/working -it lambci/lambda:build-python2.7 bash
  5. Within that Docker container, follow the README steps to set up the environment. (Note you are already root, so don’t need sudo. Also skipped these steps: sudo yum-config-manager --enable epel and alias sudo='sudo env PATH=$PATH')
  6. Within Docker container, per the README here, cd deployment and ./build-s3-dist.sh source-bucket-base-name (note that you can use anything for the bucket name since the only file you care about is the deployment/dist/serverless-image-handler.zip file that gets generated following all of this)
  7. Load that .zip into your Lamda from the AWS UI (it’s probably larger than 50MB, so will need to use S3 as an intermediate step or AWS command line if you’re fancy)
  8. Bask in the wonder of unrotated images
0reactions
mattslycommented, May 17, 2018

Sorry for the delay - I was able to get RESPECT_ORIENTATION to indeed work based on the Lamda env variable change only. I think I must have been testing w/ an already rotated image 🤦‍♂️ - closing this one out thanks for your help @stevemorad

Read more comments on GitHub >

github_iconTop Results From Across the Web

modifying Thumbor conf value on Mac OS X ... - GitHub
I need to change the Thumbor to not rotate images by default by changing this config value. RESPECT_ORIENTATION = True to avoid the...
Read more >
Configuration — Thumbor 7.2.0 documentation
If you are using thumbor's mixed storage ( thumbor.storages.mixed_storage ), this is where you specify the storage that will be used to store...
Read more >
Thumbor Documentation - Read the Docs
It enables on-demand crop, resizing and flipping of images. It features a VERY smart detection of important points in the image for better ......
Read more >
Optimize images with Thumbor - web.dev
Instructions on how to optimize images with Thumbor. Thumbor is an open-source image CDN and can be used for free to resize, compress, ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found