1

Is there a way through apex or using the VersionData of the ContentVersion for me to change that EXIF data of a ContentVersion image so that it won't register as needing to rotate?

To be more specific, a customer has been using a system where they will upload pictures to the chatter feed of a record, and it will save the image link to the ContentVersion direct download.

We then use that to output the most recent chatter post in some pages, and even in a formula on the custom object.

We found that sometimes when posting pictures from the Salesforce1 app, the pictures are saving in the EXIF metadata that the picture is rotated 90 degrees. This causes the pictures to be rendered sideways in both the formula field, and when rendered in HTML/VisualForce.

I have tried image-orientation on the tag for pages, but it isn't supported in some browsers so I'm at a loss.

1

Basically, no, you're not going to do that in Apex Code. Binary data is very challenging to work with and likely to run in to governor limits. You'll probably want to write a Lightning Component or Visualforce page that would use an HTMLCanvas to rotate images that are incorrect, or use an external service written on some platform service.

For example, we have an AWS EB (Amazon Web Service Elastic Beanstalk) that retrieves new images from user uploads, uses Image Magick to scale the images, and then saves them back to Salesforce. You could use a similar principle to design a system that could run on the cloud somewhere to do this processing.

However, with our move to Lightning, we're planning on rewriting this code to run native in the browser to avoid the overhead of maintaining our EB server. This would be done via a canvas that rescales the images and then saves them to the server.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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