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?
Forum Updated to NodeBB v4.3 + New Features

How to set JPEG compression level?

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 3 Posters 3.3k 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.
  • A Offline
    A Offline
    amahta
    wrote on 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

    mrjjM kshegunovK 2 Replies Last reply
    0
    • A amahta

      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.

      mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on 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
      0
      • A amahta

        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.

        kshegunovK Offline
        kshegunovK Offline
        kshegunov
        Moderators
        wrote on 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
        1
        • mrjjM mrjj

          @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 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
          • kshegunovK kshegunov

            @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 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

            kshegunovK 1 Reply Last reply
            0
            • A amahta

              @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.

              kshegunovK Offline
              kshegunovK Offline
              kshegunov
              Moderators
              wrote on 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

              • Login

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