Back

[SOLVED] Cloud Function breaks when resizing jpg image

  • 1
  • Functions
VincentGe
22 Feb, 2023, 22:31

You can actually use the Appwrite storage service πŸ˜‰

TL;DR
Cloud Function breaks when resizing jpg image Problem: Cloud Function breaks when resizing jpg image. Solution: Use the Appwrite storage service, which provides image resizing functionality. You can find more information in the documentation: https://appwrite.io/docs/client/storage?sdk=web-default#storageGetFilePreview
VincentGe
22 Feb, 2023, 22:31

It provides image resizing

Iron
22 Feb, 2023, 22:31

Wait, really?

VincentGe
22 Feb, 2023, 22:32
VincentGe
22 Feb, 2023, 22:32

We do have basic image manipulation

VincentGe
22 Feb, 2023, 22:35

Requires these for alpine:

VincentGe
22 Feb, 2023, 22:35
TypeScript
sudo apk add tiff-dev jpeg-dev openjpeg-dev zlib-dev freetype-dev lcms2-dev \
    libwebp-dev tcl-dev tk-dev harfbuzz-dev fribidi-dev libimagequant-dev \
    libxcb-dev libpng-dev
Drake
22 Feb, 2023, 22:35

ya, but the odd thing is the build worked fine

VincentGe
22 Feb, 2023, 22:35

Unfortunately that isn't something we can do right now, but we're talking about it internally I think

VincentGe
22 Feb, 2023, 22:35

πŸ€” Hmmm

VincentGe
22 Feb, 2023, 22:36

It's only JPEG that needs some of these external dependencies

Iron
22 Feb, 2023, 22:36

So instead of using getFileDownload i have to use getFilePreview passing the required size? What are the downsides? What If I have images bigger than 10MB?

VincentGe
22 Feb, 2023, 22:38

There shouldn't be many if it's under 10MB. If it's over 10MB, it will be more of an issue, but rarely do you get JPGs larger than 10MB.

Maybe you can try a different runtime like Java?

VincentGe
22 Feb, 2023, 22:39

Python is weird because C-Python uses so many system packages.

VincentGe
22 Feb, 2023, 22:39

🀣 And all the image/video manipulation packages are just C-Python wrappers, basically

VincentGe
22 Feb, 2023, 22:43

@Steven Should we consider distributing a heavier python runtime, or allow them to install other dependencies?

Iron
22 Feb, 2023, 22:43

[SOLVED] Cloud Function breaks when resizing jpg image

VincentGe
22 Feb, 2023, 22:43

Is this something that Matej is still thinking about?

VincentGe
22 Feb, 2023, 22:44

I am a big Python user, and I think it's one of those quirks of Python we need to be aware of, which is the heavy reliance on lots of linux packages

Drake
22 Feb, 2023, 23:06

ya i think we plan to add customizable build steps in the future

Iron
22 Feb, 2023, 23:32

Is the resized image cached? Or does it have to resize it every time I use it?

Drake
22 Feb, 2023, 23:33

yes, it is cached

Iron
22 Feb, 2023, 23:33

Awsome

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more