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. How to set JPEG compression level?

How to set JPEG compression level?

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 3 Posters 3.2k Views
  • 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.
  • A Offline
    A Offline
    amahta
    wrote on 12 Dec 2015, 11:25 last edited by
    #1

    I'm trying to save a JPEG(*.jpg) file using QImageWriter but the compression level does not seem to respond to any values I set using setCompression method.
    Is it possible to this without using any third-party libraries?
    Any ideas are much appreciated.

    Thou shalt programme
    http://www.amin-ahmadi.com

    M K 2 Replies Last reply 12 Dec 2015, 11:56
    0
    • A amahta
      12 Dec 2015, 11:25

      I'm trying to save a JPEG(*.jpg) file using QImageWriter but the compression level does not seem to respond to any values I set using setCompression method.
      Is it possible to this without using any third-party libraries?
      Any ideas are much appreciated.

      M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 12 Dec 2015, 11:56 last edited by
      #2

      @amahta said:

      Hi I wonder if it's related to this ?
      http://asmaloney.com/2011/11/code/qimagewriter-and-writing-jpegs/

      A 1 Reply Last reply 12 Dec 2015, 12:07
      0
      • A amahta
        12 Dec 2015, 11:25

        I'm trying to save a JPEG(*.jpg) file using QImageWriter but the compression level does not seem to respond to any values I set using setCompression method.
        Is it possible to this without using any third-party libraries?
        Any ideas are much appreciated.

        K Offline
        K Offline
        kshegunov
        Moderators
        wrote on 12 Dec 2015, 12:02 last edited by
        #3

        @amahta
        Hello it depends on what the qjpeg plugin supports. Unfortunately, I can't seem to be able to find more detailed information about that plugin. Still, JPEG I believe adjusts the compression based on the quality parameter, so maybe try with setting that, instead of the compression property?

        Kind regards.

        Read and abide by the Qt Code of Conduct

        A 1 Reply Last reply 12 Dec 2015, 12:10
        1
        • M mrjj
          12 Dec 2015, 11:56

          @amahta said:

          Hi I wonder if it's related to this ?
          http://asmaloney.com/2011/11/code/qimagewriter-and-writing-jpegs/

          A Offline
          A Offline
          amahta
          wrote on 12 Dec 2015, 12:07 last edited by
          #4

          @mrjj said:

          @amahta said:

          Hi I wonder if it's related to this ?
          http://asmaloney.com/2011/11/code/qimagewriter-and-writing-jpegs/

          No unfortunately it is not. I've already seen that.

          Thou shalt programme
          http://www.amin-ahmadi.com

          1 Reply Last reply
          0
          • K kshegunov
            12 Dec 2015, 12:02

            @amahta
            Hello it depends on what the qjpeg plugin supports. Unfortunately, I can't seem to be able to find more detailed information about that plugin. Still, JPEG I believe adjusts the compression based on the quality parameter, so maybe try with setting that, instead of the compression property?

            Kind regards.

            A Offline
            A Offline
            amahta
            wrote on 12 Dec 2015, 12:10 last edited by
            #5

            @kshegunov said:

            @amahta
            Hello it depends on what the qjpeg plugin supports. Unfortunately, I can't seem to be able to find more detailed information about that plugin. Still, JPEG I believe adjusts the compression based on the quality parameter, so maybe try with setting that, instead of the compression property?

            Kind regards.

            Wow, thank you @kshegunov ! How did I miss that :)
            It works when I use setQuality

            Here is a part of setQuality documentation exactly answering my problem:

            Sets the quality setting of the image format to quality.

            Some image formats, in particular lossy ones, entail a tradeoff between a) visual quality of the resulting image, and b) encoding execution time and compression level. This function sets the level of that tradeoff for image formats that support it. For other formats, this value is ignored.
            The value range of quality depends on the image format. For example, the "jpeg" format supports a quality range from 0 (low visual quality, high compression) to 100 (high visual quality, low compression).

            Thanks again.

            Thou shalt programme
            http://www.amin-ahmadi.com

            K 1 Reply Last reply 12 Dec 2015, 15:17
            0
            • A amahta
              12 Dec 2015, 12:10

              @kshegunov said:

              @amahta
              Hello it depends on what the qjpeg plugin supports. Unfortunately, I can't seem to be able to find more detailed information about that plugin. Still, JPEG I believe adjusts the compression based on the quality parameter, so maybe try with setting that, instead of the compression property?

              Kind regards.

              Wow, thank you @kshegunov ! How did I miss that :)
              It works when I use setQuality

              Here is a part of setQuality documentation exactly answering my problem:

              Sets the quality setting of the image format to quality.

              Some image formats, in particular lossy ones, entail a tradeoff between a) visual quality of the resulting image, and b) encoding execution time and compression level. This function sets the level of that tradeoff for image formats that support it. For other formats, this value is ignored.
              The value range of quality depends on the image format. For example, the "jpeg" format supports a quality range from 0 (low visual quality, high compression) to 100 (high visual quality, low compression).

              Thanks again.

              K Offline
              K Offline
              kshegunov
              Moderators
              wrote on 12 Dec 2015, 15:17 last edited by
              #6

              @amahta
              I'm glad it worked.
              Cheers.

              Read and abide by the Qt Code of Conduct

              1 Reply Last reply
              0

              5/6

              12 Dec 2015, 12:10

              • Login

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