🤖Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    M5Paper: How to display large jpg image from web (or download it to SD card)

    SOFTWARE
    2
    3
    6.5k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • D
      doubleness
      last edited by

      Hello!

      I am new to m5stack, arduino/micropython and ESP32 development overall, and I was wondering if anybody here could help me and give me advice what would be best way to go about displaying larger jpg images (~1MB) directly from web on m5paper.

      I was able to draw small example image "flower.jpg" using
      canvas.drawJpgUrl("https://m5stack.oss-cn-shenzhen.aliyuncs.com/image/example_pic/flower.jpg");

      But I understand I cant draw larger images this way, directly from the web, so I was thinking I would download the image to SD card first and then display it (since that works for large images)

      Any ideas if there is a better way to do this and what I should look into?

      Thank you!

      PS: I found that maybe I could modify this example to download images, but it is a bit complicated for me to understand everything:
      https://github.com/esp8266/Arduino/blob/master/libraries/ESP8266HTTPClient/examples/StreamHttpClient/StreamHttpClient.ino

      1 Reply Last reply Reply Quote 0
      • felmueF
        felmue
        last edited by

        Hello @doubleness

        M5Paper has 8MB of PSRAM on board of which 4MB can be used at the time. (The limitation is ESP32 which only can map 4MB at the time).
        And canvas.drawJpgUrl() already makes use of PSRAM by calling ps_malloc():

            uint8_t *p = (uint8_t*)ps_malloc(size);
            if(p == NULL)
            {
                log_e("Memory overflow.");
                return 0;
            }
        

        In my test I was able to directly download and display jpgs up to about 4MB. (No SD card involved.)

        Thanks
        Felix

        GPIO translation table M5Stack / M5Core2
        Information about various M5Stack products.
        Code examples

        D 1 Reply Last reply Reply Quote 0
        • D
          doubleness @felmue
          last edited by

          @felmue Thanks Felix, I tested different urls with several jpg images and it is really working.

          I was probably testing either images with wrong format or simply didn't wait long enough until the image is drawn. And not sure why, I was under impression that images need to be smaller than 50KB ... my bad.

          Thanks again, you saved me a lot of headache :)

          1 Reply Last reply Reply Quote 0
          • First post
            Last post