This is the script I run

#!/usr/bin/env python

from datetime import datetime

from picamera import PiCamera
from time import sleep

camera = PiCamera()

camera.rotation = 180
#camera.resolution = (1920, 1080)
#camera.annotate_text = str(datetime.now().time())


for i in range(5):
        camera.capture('tst/img%02d.png' % i)


When the preview starts the camera is quite zoomed in but when it takes a picture it zooms out and the picture is zoomed out.

Why is it zooming in and what can I do to avoid it?


I think the issue you're describing looks a lot like this one described on the PiCamera Github page. User waveform80, who maintains the library, provided this explanation back in 2013:

...the only time the preview matches the capture area at the moment is when the camera's resolution is set to maximum (2592x1944). At any resolution other than that, the preview is drawn from the 1920x1080 pixels at the centre of the camera's sensor (the "video area") and scaled to the requested resolution, while the capture uses the full area (scaled down to the requested resolution). That's what the bit at the end of the Preview vs Still Resolution is going on about. Unfortunately this just seems to be an artifact of the way the preview port of the camera works.

The discussion there leads to this example, again on Github, which seems to work around the problem through appending the use_video_port = True option to the camera.capture() command.

  • Thanks, use_video_port doesn't do what I want though, when I run with it - it always shows the preview size without zooming out, but I want to always see the zoomed out version, in which the picture will be taken. I'll accept this though, since it doesn't seem like there is a solution.
    – LLL
    Jun 5 '17 at 12:43
  • I think you're probably right, although it might be worth tinkering with setting the camera resolution to its maximum per the quoted comment in my answer. It seems to be suggesting that setting to max resolution will render the preview at full size (I think).
    – goobering
    Jun 5 '17 at 13:14
  • I'm planning on setting it up without a screen and sending stills to my laptop anyway, so it doesn't bother me that much that the zoom is changing, just a little weird now that I'm testing it.
    – LLL
    Jun 5 '17 at 14:47
  • 1
    Yes - when capturing with the still port (when use_video_port=False, the default), the camera's firmware performs a temporary mode switch to mode 2 or 3 while performing the capture. If you force that mode (with sensor_mode in the constructor, or by selecting an appropriate res + framerate) you won't get the "zoom". However, beware that on the V2 module you can't run the preview at full res
    – Dave Jones
    Jun 8 '17 at 7:50

you can show the display preview indicating the weight and height as follows: raspivid -t 0 -fps 25 -w 640 -h 480

Change the resolution as you prefer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.