Resize Image Before Upload

Stable Version 1.1.1 (OutSystems 11)
Published on 6 Nov (7 days ago) by 
Created on 5 Nov (8 days ago)
Details
Client-side Resize, Sharpen, Fix Orientation, JPEG Compression Quality using Javascript... HUGE file size savings (kilobytes, even megabytes).
Read More

Client-side Image Resize Before Upload, with many options:

1. Resize: resize a Maximum Resolution, Width or Height (maintain aspect ratio), default 800px.

2. Gradual Resize: resize large resolution image beautifully using gradual resize, default true.

3. Sharpen: sharpen factor default 0.2

4. Fix Orientation: reading EXIF data then fixing orientation, default true

5. Jpeg Quality: jpeg compression, default 0.7

7. Reset Upload Element After Resize: default true, to prevent accidental file re-upload on Submit.

8. Bonus: Upload element automatically set to accept: "image/*"

9. Dual Mode Resized Image Output: (hidden/display: none) text input field or Event.


Quick How To:

1. Add and name Upload Widget (optionally with File Upload widget that support drag and drop)

2. Optionally, add and name Image Widget for Preview

3. Add ResizeImageBeforeUpload webblock (add dependency first)

Now, it depends on which mode do you want to use:



FORM HIDDEN TEXT INPUT MODE

4. Add Form Widget and then under it, add & name Text Input Widget

5. Set Text Input Widget's Max Length to 999,999,999,999 and set Style extended property to "display: none;" (don't set Visible to false, it won't work)

7. Add button to ajax submit or submit form

If you use submit, remember to check ResetUploadWidgetBeforeResize is true (default already true), otherwise image will be uploaded twice during submit.

8. Set ResizeImageBeforeUpload webblock's input parameters like in screenshot above.

9. Make sure you input the id of text input widget in OutputWidgetId parameter.

10. During submit/ajax submit action, use Base64ToBinary (from BinaryData system extension) to convert it back to binary

11. Save binary to database entity.


EVENT MODE

4. Set ResizeImageBeforeUpload webblock's input parameters like in screenshot above.

5. Make sure OutputWidgetId parameter is empty.

6. Resized Image will be received using webblock's ImageResized event.

7. Create ImageResized Event Handler

8. Save image to Database Entity in the Event Handler.


Never save image to local variable then use in screen action!

If you do that, image binary will be added to View State, very slow!

Either use form variable, or pass local variable as input parameter to submit action.


Limitation:

- This is not a UI Cropper (where you can control using interaction), use Cropper plugin instead.

- Currently only tested for Chrome browser and Android (as I don't have Mac/Safari/iPhone)


Sample/How-to App included.


Powered by my other Forge Component's javascript: Image Utils Mobile.

Check it out: https://www.outsystems.com/forge/component-overview/2078/image-utils-mobile


Anyone want to donate :)

I received donation through Paypal at harlins@gmail.com.


What’s new (1.1.1)

Fix bug in javascript parameters.

Reviews (0)
Category
Components
Support Options
This component is not supported by OutSystems. You may use the discussion forums to leave suggestions or obtain best-effort support from the community, including from Harlin Setiadarma who created this component.
Dependencies
Resize Image Before Upload has no dependencies.
Requirements
Platform:
11.0.0.200
Database:
All
Stack:
.NET
Component Consumers
No consumers yet.
Weekly Downloads