#1501·OCRmyPDF

[Bug]: Page not rotating with --rotate-pages (inconsistent results)

Author: nacholibreCreated Mar 28, 2025Updated Dec 30, 2025
Labelstriage

Describe the bug

I'm testing the --rotate-pages feature but I get inconsistent results. Some pages are rotated, but others are not when clearly they need to be rotated.

Steps to reproduce

plain
Run `ocrmypdf -l bul --rotate-pages not_rotated.pdf not_rotated_processed.pdf`

The output says:

`page is facing ⇧, confidence 0.00 - no change`

After some digging I found a few things.

First I tried to run the image via tesseract directly.

bash
$ tesseract not_rotated.png stdout --psm 0
Too few characters. Skipping this page
Error during processing.

With characters tweak:

bash
$ tesseract not_rotated.png stdout --psm 0 -c min_characters_to_try=20
Page number: 0
Orientation in degrees: 270
Rotate: 90
Orientation confidence: 0.03
Script: Latin
Script confidence: 0.00

At the same time when I run it in python script:

python
import pytesseract
from pytesseract import Output
from PIL import Image
import os

if __name__ == "__main__":
    # Load the image file
    image_path = "not_rotated.png"

    # Open the image using PIL
    image = Image.open(image_path)

    # Convert to grayscale for OSD (Orientation and Script Detection)
    #gray_for_osd = image.convert('L')

    # Get orientation and script information
    osd_dict = pytesseract.image_to_osd(image, output_type=Output.DICT)
    print("Orientation and Script Detection (OSD):")
    for key, value in osd_dict.items():
        print(f"{key}: {value}")

I get

bash
$  image_processor git:(ra_parser) ✗ python test.py
Orientation and Script Detection (OSD):
page_num: 0
orientation: 180
rotate: 180
orientation_conf: 0.19
script: Cyrillic
script_conf: 33.33

Which is odd, the script language Cyrillic is properly detected and the orientation_conf is now 19%.

I'm not quite sure what is happening.

Files

example_file.pdf

How did you download and install the software?

PyPI (pip, poetry, pipx, etc.)

OCRmyPDF version

16.10.0

Relevant log output

plain
➜  Downloads ocrmypdf -l bul --rotate-pages not_rotated.pdf not_rotated_processed.pdf -v1
ocrmypdf 16.10.0                                                                                                                                                                                                                 __main__.py:59
Running: ['tesseract', '--version']                                                                                                                                                                                             __init__.py:133
Found tesseract 5.5.0                                                                                                                                                                                                           __init__.py:345
Running: ['tesseract', '--version']                                                                                                                                                                                             __init__.py:133
Running: ['tesseract', '--version']                                                                                                                                                                                             __init__.py:133
Running: ['gs', '--version']                                                                                                                                                                                                    __init__.py:133
Found gs 10.4.0                                                                                                                                                                                                                 __init__.py:345
Running: ['gs', '--version']                                                                                                                                                                                                    __init__.py:133
Running: ['tesseract', '--list-langs']                                                                                                                                                                                          __init__.py:133
stdout/stderr = List of available languages in "/opt/homebrew/share/tessdata/" (163):                                                                                                                                            __init__.py:73
afr
amh
ara
asm
aze
aze_cyrl
bel
ben
bod
bos
bre
bul
cat
ceb
ces
chi_sim
chi_sim_vert
chi_tra
chi_tra_vert
chr
cos
cym
dan
deu
div
dzo
ell
eng
enm
epo
equ
est
eus
fao
fas
fil
fin
fra
frk
frm
fry
gla
gle
glg
grc
guj
hat
heb
hin
hrv
hun
hye
iku
ind
isl
ita
ita_old
jav
jpn
jpn_vert
kan
kat
kat_old
kaz
khm
kir
kmr
kor
kor_vert
lao
lat
lav
lit
ltz
mal
mar
mkd
mlt
mon
mri
msa
mya
nep
nld
nor
oci
ori
osd
pan
pol
por
pus
que
ron
rus
san
script/Arabic
script/Armenian
script/Bengali
script/Canadian_Aboriginal
script/Cherokee
script/Cyrillic
script/Devanagari
script/Ethiopic
script/Fraktur
script/Georgian
script/Greek
script/Gujarati
script/Gurmukhi
script/HanS
script/HanS_vert
script/HanT
script/HanT_vert
script/Hangul
script/Hangul_vert
script/Hebrew
script/Japanese
script/Japanese_vert
script/Kannada
script/Khmer
script/Lao
script/Latin
script/Malayalam
script/Myanmar
script/Oriya
script/Sinhala
script/Syriac
script/Tamil
script/Telugu
script/Thaana
script/Thai
script/Tibetan
script/Vietnamese
sin
slk
slv
snd
snum
spa
spa_old
sqi
srp
srp_latn
sun
swa
swe
syr
tam
tat
tel
tgk
tha
tir
ton
tur
uig
ukr
urd
uzb
uzb_cyrl
vie
yid
yor

pikepdf mmap enabled                                                                                                                                                                                                             helpers.py:328
os.symlink(not_rotated.pdf, /var/folders/ld/4yfqp9l56flgj37n40j5zms00000gn/T/ocrmypdf.io.8kz0lw8q/origin)                                                                                                                        helpers.py:179
Gathering info with 1 thread workers                                                                                                                                                                                                info.py:816
pikepdf mmap enabled                                                                                                                                                                                                             helpers.py:328
Scanning contents     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 1/1 0:00:00
Using Tesseract OpenMP thread limit 3                                                                                                                                                                                      tesseract_ocr.py:199
pikepdf mmap enabled                                                                                                                                                                                                             helpers.py:328
    1 Running: ['gs', '-dSAFER', '-dBATCH', '-dNOPAUSE', '-dInterpolateControl=-1', '-sDEVICE=jpeggray', '-dFirstPage=1', '-dLastPage=1', '-r192.000000x192.000000', '-dPDFSTOPONERROR', '-o',                                  __init__.py:133
'/var/folders/ld/4yfqp9l56flgj37n40j5zms00000gn/T/ocrmypdf.io.8kz0lw8q/000001_rasterize_preview.jpg', '-sstdout=%stderr', '-dAutoRotatePages=/None', '-f',
'/var/folders/ld/4yfqp9l56flgj37n40j5zms00000gn/T/ocrmypdf.io.8kz0lw8q/origin.pdf']
    1 stderr = GPL Ghostscript 10.04.0 (2024-09-18)                                                                                                                                                                              __init__.py:75
Copyright (C) 2024 Artifex Software, Inc.  All rights reserved.
This software is supplied under the GNU AGPLv3 and comes with NO WARRANTY:
see the file COPYING for details.
Processing pages 1 through 1.
Page 1

    1 Rotating output by 0                                                                                                                                                                                                   ghostscript.py:161
    1 Running: ['tesseract', '-l', 'osd', '--psm', '0', '/var/folders/ld/4yfqp9l56flgj37n40j5zms00000gn/T/ocrmypdf.io.8kz0lw8q/000001_rasterize_preview.jpg', 'stdout']                                                         __init__.py:133
    1 [tesseract] Too few characters. Skipping this page                                                                                                                                                                       tesseract.py:259
    1 [tesseract] Error during processing.                                                                                                                                                                                     tesseract.py:253
    1 page is facing ⇧, confidence 0.00 - no change                                                                                                                                                                            _pipeline.py:460
    1 Rasterize with pnggray, rotation 0                                                                                                                                                                                       _pipeline.py:552
    1 Running: ['gs', '-dSAFER', '-dBATCH', '-dNOPAUSE', '-dInterpolateControl=-1', '-sDEVICE=pnggray', '-dFirstPage=1', '-dLastPage=1', '-r192.000000x192.000000', '-dPDFSTOPONERROR', '-o',                                   __init__.py:133
'/var/folders/ld/4yfqp9l56flgj37n40j5zms00000gn/T/ocrmypdf.io.8kz0lw8q/000001_rasterize.png', '-sstdout=%stderr', '-dAutoRotatePages=/None', '-f',
'/var/folders/ld/4yfqp9l56flgj37n40j5zms00000gn/T/ocrmypdf.io.8kz0lw8q/origin.pdf']
    1 stderr = GPL Ghostscript 10.04.0 (2024-09-18)                                                                                                                                                                              __init__.py:75
Copyright (C) 2024 Artifex Software, Inc.  All rights reserved.
This software is supplied under the GNU AGPLv3 and comes with NO WARRANTY:
see the file COPYING for details.
Processing pages 1 through 1.
Page 1

    1 resolution (191.99859999999998, 191.99859999999998)                                                                                                                                                                      _pipeline.py:631
    1 Running: ['tesseract', '-l', 'bul', '/var/folders/ld/4yfqp9l56flgj37n40j5zms00000gn/T/ocrmypdf.io.8kz0lw8q/000001_ocr.png', '/var/folders/ld/4yfqp9l56flgj37n40j5zms00000gn/T/ocrmypdf.io.8kz0lw8q/000001_ocr_hocr',      __init__.py:133
'hocr', 'txt']
    1 pikepdf.Matrix(0.375, 0, 0, -0.375, 0, 822.375)                                                                                                                                                                              _hocr.py:219
    1 bul                                                                                                                                                                                                                          _hocr.py:283
    1 bul                                                                                                                                                                                                                          _hocr.py:283
    1 bul                                                                                                                                                                                                                          _hocr.py:283
    1 bul                                                                                                                                                                                                                          _hocr.py:283
    1 bul                                                                                                                                                                                                                          _hocr.py:283
    1 bul                                                                                                                                                                                                                          _hocr.py:283
    1 bul                                                                                                                                                                                                                          _hocr.py:283
    1 bul                                                                                                                                                                                                                          _hocr.py:283
    1 bul                                                                                                                                                                                                                          _hocr.py:283
    1 bul                                                                                                                                                                                                                          _hocr.py:283
    1 bul                                                                                                                                                                                                                          _hocr.py:283
    1 bul                                                                                                                                                                                                                          _hocr.py:283
    1 bul                                                                                                                                                                                                                          _hocr.py:283
    1 bul                                                                                                                                                                                                                          _hocr.py:283
    1 bul                                                                                                                                                                                                                          _hocr.py:283
    1 bul                                                                                                                                                                                                                          _hocr.py:283
    1 bul                                                                                                                                                                                                                          _hocr.py:283
    1 bul                                                                                                                                                                                                                          _hocr.py:283
    1 bul                                                                                                                                                                                                                          _hocr.py:283
    1 bul                                                                                                                                                                                                                          _hocr.py:283
    1 bul                                                                                                                                                                                                                          _hocr.py:283
    1 bul                                                                                                                                                                                                                          _hocr.py:283
    1 bul                                                                                                                                                                                                                          _hocr.py:283
    1 bul                                                                                                                                                                                                                          _hocr.py:283
    1 bul                                                                                                                                                                                                                          _hocr.py:283
    1 bul                                                                                                                                                                                                                          _hocr.py:283
    1 bul                                                                                                                                                                                                                          _hocr.py:283
    1 bul                                                                                                                                                                                                                          _hocr.py:283
    1 bul                                                                                                                                                                                                                          _hocr.py:283
    1 bul                                                                                                                                                                                                                          _hocr.py:283
    1 bul                                                                                                                                                                                                                          _hocr.py:283
    1 bul                                                                                                                                                                                                                          _hocr.py:283
    1 bul                                                                                                                                                                                                                          _hocr.py:283
    1 bul                                                                                                                                                                                                                          _hocr.py:283
    1 bul                                                                                                                                                                                                                          _hocr.py:283
    1 bul                                                                                                                                                                                                                          _hocr.py:283
    1 bul