Skip to main content

Notifications

Power Apps - Building Power Apps
Unanswered

Compressing images

(0) ShareShare
ReportReport
Posted on by 395

Hi, i have a powerapp jobcard that saves to a collection when submitted. It is then patch to sharepoint when online. The problem i am having is when someone attaches to many photos, it will not upload to sharepoint. There is no error messages just doesnt patch through. Is there a way to compress the images before sending to sharepoint?

Categories:
  • Digital Profile Picture
    Digital 1,199 on at
    Re: Compressing images

    I have run into this problem in the past when embedding images in a PDF using Flow. It seems crazy there is only a 2MB limit.

     

    I got around it by using the Power Apps print screen to display a printer friendly view with embedded images. You can then use the browser to print to PDF.

     

    https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-print 

  • WarrenBelz Profile Picture
    WarrenBelz 145,422 on at
    Re: Compressing images

    Hi @Matt383 ,

    Yes that would do it as well (I strike it doing PDF files on pictures), but there is no alternative I know of (and this has been confirmed in a couple of videos I have seen, particularly one from @RezaDorrani )

  • Matt383 Profile Picture
    Matt383 395 on at
    Re: Compressing images

    Hi Warren, i had a look in the flow history and think i may of identified the issue;

    The html content length cannot be greater than 2 MB
    InnerExceptionMessage:

     

    Do you know of a  way around this without using encodian?

  • WarrenBelz Profile Picture
    WarrenBelz 145,422 on at
    Re: Compressing images

    Hi @Matt383 ,

    So the second one is saving Base64 text into multi-line text fields? I assume the first one (you mentioned HTML) is embedding these in a PDF generated from OneDrive? Which one is not working (I assume the second one).I must admit we are on a very different path to what I imagined from your initial post and I cannot guarantee I will have anything useful to explain your issue (which I have never encountered).

  • Matt383 Profile Picture
    Matt383 395 on at
    Re: Compressing images

    Hi Warren, yes, first code uses base64 and the flow converts data from collection into html.
    The 2nd code is to patch to sharepoint. In regards to the image, this is a sample of what is transferred over to sharepoint.

    data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAASABIAAD/4QBYRXhpZgAATU0AKgAAHRUUdsl4Afm...

     

  • WarrenBelz Profile Picture
    WarrenBelz 145,422 on at
    Re: Compressing images

    Hi @Matt383 ,

    In the first code, there is a Flow involved and you are sending JSON (I assume Base64 Text) to it, so I suspect the issue lies there. In the second code what type of fields are you patching the images to?

  • Matt383 Profile Picture
    Matt383 395 on at
    Re: Compressing images

    Hi Warren,

    both samples below are on the same submit button.

    Patch(KBXCollection,ThisItem,{Submitted:true});
    'PDFconvert-2'.Run('PDFconvert-2'.Run("<!DOCTYPE html>
    <p><img src="&JSON(CollectGallery.Selected.Image5, JSONFormat.IgnoreBinaryData)&"</p>
    <p>&nbsp;</p>.....

     

    Patch(KBX_Jobcard, Defaults(KBX_Jobcard),{Title: CollectGallery.Selected.Title,Date: CollectGallery.Selected.Date,Image1: CollectGallery.Selected.Image1,Image2: CollectGallery.Selected.Image2,Image3: CollectGallery.Selected.Image3,Image4: CollectGallery.Selected.Image4.....

  • WarrenBelz Profile Picture
    WarrenBelz 145,422 on at
    Re: Compressing images

    Hi @Matt383 ,

    Very strange (I was expecting much bigger numbers). What is your Patch code (in a Code box </> if possible)?

  • Matt383 Profile Picture
    Matt383 395 on at
    Re: Compressing images

    Hi Warren, 4 images. Ranging from 1mb - 4mb per image. If the images are small they go through fine, otherwise, the user has to delete images until it sends.

  • WarrenBelz Profile Picture
    WarrenBelz 145,422 on at
    Re: Compressing images

    Hi @Matt383 ,

    No unfortunately - how many photos are you talking about here and how big are the photos?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,422

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,711

Leaderboard