0

This question already has an answer here:

I can upload 1 MB images in visual force, it will be store in Document Object. Other wise if i Upload more then 1 MB images in Visual force page It will be Display Error Message

marked as duplicate by AtulRajguru9, martin, Ratan Paul, Adrian Larson, sfdcfox visualforce Aug 24 '16 at 15:03

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • @ Nick Cook, Thank you for your response, we have 500 Kb Image, Once we click the Uploaded Button , The Image will be compressed to Display in visualforce page and Saved in Attachments please give any suggestions.. – Abd Al Aug 24 '16 at 6:49
  • @Abdulmasood, Did u check the link provided by Nick? – Robert Thomas Aug 24 '16 at 7:00
  • Yes @Robert thomas .. I Checked that link. That is not working properlly .. i means not selected / uploaded images .. and also i want to be compress the image size Thanks also not match i scenario ----- See the above image – Abd Al Aug 24 '16 at 7:09
2

The Salesforce server-side-language Apex does not include the byte-level access that would be needed to implement compression there (or include an API for image compression). That leaves you with choices such as:

  • Do the compression on the client-side in JavaScript
  • Make a HTTP callout on the server-side to a service such as https://tinypng.com/developers (there is a charge for that but it is very small)

From a quick Google the former approach looks like the first one to try. In particular there is this open-source JavaScript you could use https://github.com/brunobar79/J-I-C. There is a demonstration of that at http://makeitsolutions.com/labs/jic/. (I have not tried it so can't offer any help on it.)

  • any one can you please give some suggestions of above requirement.... – Abd Al Aug 24 '16 at 12:18

Not the answer you're looking for? Browse other questions tagged or ask your own question.