waveform80 / picamera

A pure Python interface to the Raspberry Pi camera module
https://picamera.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
1.57k stars 355 forks source link

JPEG "quality" argument ignored? #706

Open qgeissmann opened 3 years ago

qgeissmann commented 3 years ago

Hello, I am using the pi camera HQ, on archlinux arm, and picamera==1.13 and attempting to set JPEG quality during capture. Adapting the documentation recipe:

import time
import picamera
with picamera.PiCamera() as camera:
    camera.resolution = (1024, 768)
    camera.start_preview()
    # Camera warm-up time
    time.sleep(2)
    camera.capture('foo.jpg', quality=90)

I notice my images are the same approximate size regardless of what value I set for quality. Using ImageMagick's identify confirms Quality is actually 100, not 90 as set:

identify -verbose /run/media/quentin/SPI_DRIVE/foo.jpg  | grep Quality
  Quality: 100

The documentation says:

Certain file formats accept additional options which can be specified as keyword arguments. Currently, only the 'jpeg' encoder accepts additional options, which are: quality - Defines the quality of the JPEG encoder as an integer ranging from 1 to 100. Defaults to 85. Please note that JPEG quality is not a percentage and definitions of quality vary widely.

It seems that the default is actually 100 for this camera/setup? Does anyone else have the same pproblem or a solution?

6by9 commented 3 years ago

As in the docs:

definitions of quality vary widely

Picamera's quality parameter does not match with ImageMagick's. Such is life.