Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Function that return the file size of a formated resized AND copressed QImage before save()?

Function that return the file size of a formated resized AND copressed QImage before save()?

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 3 Posters 513 Views 2 Watching
  • 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.
  • M Offline
    M Offline
    MikeLemon
    wrote on last edited by
    #1

    Hi,

    I'm looking for a way to determine the file size of a QImage that got loaded formated and resized without saving it to memory to prevent unnecessary wear of SSD drives, The method sizeInBytes() only gives the formated and resized file size of the image but I'd like to get the file size after saving the image with a given "Quality".

    Is there such a function that does that without saving the compressed image on memory, or atleast something that saved the output to ram temporary and allow measurement from there?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      AFAIK, no.

      What you can do is use a RAM disk as target and then move the file on your disk when satisfied.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      M 1 Reply Last reply
      1
      • SGaistS SGaist

        Hi,

        AFAIK, no.

        What you can do is use a RAM disk as target and then move the file on your disk when satisfied.

        M Offline
        M Offline
        MikeLemon
        wrote on last edited by
        #3

        @SGaist Ok Thanks just wanted to get that clear. Do you have a quick snippet to moving the Compressed QImage to RAM temporarlly instead of to permanent memory?

        1 Reply Last reply
        0
        • C Offline
          C Offline
          ChrisW67
          wrote on last edited by
          #4

          You can QImage::save() to a suitable QIODevice. QBuffer provides the QIODevice interface to a QByteArray, so the entire process stays in RAM.

          SGaistS 1 Reply Last reply
          3
          • C ChrisW67

            You can QImage::save() to a suitable QIODevice. QBuffer provides the QIODevice interface to a QByteArray, so the entire process stays in RAM.

            SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @ChrisW67 nice ! I forgot about this one and it is even better than what I had I mind !

            The QImage::save overload has a code snippet that shows how to do it.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            C 1 Reply Last reply
            0
            • SGaistS SGaist

              @ChrisW67 nice ! I forgot about this one and it is even better than what I had I mind !

              The QImage::save overload has a code snippet that shows how to do it.

              C Offline
              C Offline
              ChrisW67
              wrote on last edited by
              #6

              @SGaist said:

              it is even better than what I had I mind

              It is all roses until someone feeds you a 3.5GB image file or two.

              SGaistS 1 Reply Last reply
              0
              • C ChrisW67

                @SGaist said:

                it is even better than what I had I mind

                It is all roses until someone feeds you a 3.5GB image file or two.

                SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #7

                @ChrisW67 said in Function that return the file size of a formated resized AND copressed QImage before save()?:

                @SGaist said:

                it is even better than what I had I mind

                It is all roses until someone feeds you a 3.5GB image file or two.

                On 32 bit variant of the application ? :-)

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved