function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
__sandra____sandra__ 

Image resizer in Apex

Hi,

 

I am using force.com sites, and the guest users are allowed to fill a form and submit images.

 

But I would like to resize the images in order to use them.

 

For instance, if I have a submitted image of 3 mega, I would like to make a copy having 200Ko as size.

 

Is it possible to do that with apex ou an API or whatever?

 

Thank you!

 

 

sfdcfoxsfdcfox

Terse answer: no.

 

Slightly less terse answer: maybe, but it would take work.

 

Verbose answer: Basically, you can't really manipulate binary data of any type in Apex Code (you can, but I'm not going to recommend it, and you would be limited to very small data sizes anyways, maybe up to a 2kb file or so), but what you can do is take that file's contents, throw it at an external soap- or rest-based image resizer script, and then take the results and store them in the system. You'll still need to limit the uploads to approximately 1.6 MB per image, as that's about when you'll run into the callout governor limits (better performance with rest, though, since there's less protocol overhead). You'll need an external resizing service, though.

__sandra____sandra__

thank you sfdcfox

 

but do you know an external resizing service?

 

diane21diane21

My favorite photo editor is available here. I like also being able to use it to fix brightness and contrast issues, white balance, and cropping. It's a very powerful photo editor.