Evals / pdf / Read a PDF

Pull out the pictures

Save every picture embedded in paper.pdf into a folder called pictures.

The task

The reference answer shows the job can be done with deft. It is not an agent run.

deft pdf extract-images paper.pdf -o pictures/

Input

paper.pdf 992.5 KB · 14 pages
Page 1Page 2Page 3

Reference output

And 74 more files.

How a result is judged (1 check)
  • count_files: glob = "pictures/*", min = 10

Runs

CodexWithout deftPassed2026-11-07

Time
37s
New tokens
14.0k
Total input
117.1k
Output tokens
1.0k
Commands
7
Failed
1

Trace

  1. I’ll inspect the PDF and extract its embedded images into `pictures` in the current directory.

  2. ls -la && file paper.pdf
    output
    total 1992
    drwxr-xr-x@    3 user  staff       96 Nov  6 17:17 .
    drwx------@ 1718 user  staff    54976 Nov  6 17:18 ..
    -rw-r--r--@    1 user  staff  1016315 Nov  5 21:11 paper.pdf
    paper.pdf: PDF document, version 1.4, 6 pages
  3. command -v pdfimages || command -v mutool || command -v pdftoppm (exit 1)
  4. python3 -c 'import importlib.util as u; print({x:bool(u.find_spec(x)) for x in [\"fitz\",\"pypdf\",\"pdf2image\",\"PIL\",\"pikepdf\"]})'
    output
    {'fitz': False, 'pypdf': False, 'pdf2image': False, 'PIL': True, 'pikepdf': False}
  5. for x in gs qpdf pdfinfo pdftotext convert magick sips swift; do command -v "$x"; done; python3 -m pip list --format=columns
    output
    /usr/local/bin/gs
    /usr/bin/sips
    /usr/bin/swift
    Package            Version
    ------------------ -----------
    contourpy          1.3.3
    cycler             0.12.1
    fonttools          4.62.1
    kiwisolver         1.5.0
    matplotlib         3.10.8
    numpy              2.4.4
    packaging          26.0
    pandas             3.0.2
    pillow             12.2.0
    pip                24.3.1
    pyparsing          3.3.2
    python-dateutil    2.9.0.post0
    quantconnect-stubs 17649
    six                1.17.0
  6. gs -h | head -45; strings paper.pdf | head -50
    output
    GPL Ghostscript 9.55.0 (2021-09-27)
    Copyright (C) 2021 Artifex Software, Inc.  All rights reserved.
    Usage: gs [switches] [file1.ps file2.ps ...]
    Most frequently used switches: (you can use # in place of =)
     -dNOPAUSE           no pause after page   | -q       `quiet', fewer messages
     -g<width>x<height>  page size in pixels   | -r<res>  pixels/inch resolution
     -sDEVICE=<devname>  select device         | -dBATCH  exit after last file
     -sOutputFile=<file> select output file: - for stdout, |command for pipe,
                                             embed %d or %ld for page #
    Input formats: PostScript PostScriptLevel1 PostScriptLevel2 PostScriptLevel3 PDF
    Default output device: bbox
    Available devices:
       alc1900 alc2000 alc4000 alc4100 alc8500 alc8600 alc9100 ap3250 appledmp
       atx23 atx24 atx38 bbox bit bitcmyk bitrgb bitrgbtags bj10e bj10v bj10vh
       bj200 bjc600 bjc800 bjc880j bjccmyk bjccolor bjcgray bjcmono bmp16 bmp16m
       bmp256 bmp32b bmpgray bmpmono bmpsep1 bmpsep8 ccr cdeskjet cdj1600 cdj500
       cdj550 cdj670 cdj850 cdj880 cdj890 cdj970 cdjcolor cdjmono cdnj500 cfax
       chp2200 cif cljet5 cljet5c cljet5pr coslw2p coslwxl cups declj250 deskjet
       devicen dfaxhigh dfaxlow display dj505j djet500 djet500c dl2100 dnj650c
       docxwrite epl2050 epl2050p epl2120 epl2500 epl2750 epl5800 epl5900
       epl6100 epl6200 eplcolor eplmono eps2write eps9high eps9mid epson epsonc
       escp escpage faxg3 faxg32d faxg4 fmlbp fmpr fpng fs600 gdi hl1240 hl1250
       hl7x0 hocr hpdj1120c hpdj310 hpdj320 h
    … 1971 more characters
  7. Ghostscript includes a PDF image extraction device, so I can extract image objects directly instead of saving full page renders.

  8. mkdir -p pictures && gs -q -dBATCH -dNOPAUSE -sDEVICE=pdfimage24 -sOutputFile=pictures/image-%03d.png paper.pdf && ls -lh pictures && file pictures/*
    output
    total 22568
    -rw-r--r--@ 1 user  staff   712K Nov  6 17:18 image-001.png
    -rw-r--r--@ 1 user  staff   882K Nov  6 17:18 image-002.png
    -rw-r--r--@ 1 user  staff   636K Nov  6 17:18 image-003.png
    -rw-r--r--@ 1 user  staff   970K Nov  6 17:18 image-004.png
    -rw-r--r--@ 1 user  staff   1.0M Nov  6 17:18 image-005.png
    -rw-r--r--@ 1 user  staff   787K Nov  6 17:18 image-006.png
    -rw-r--r--@ 1 user  staff   769K Nov  6 17:18 image-007.png
    -rw-r--r--@ 1 user  staff   868K Nov  6 17:18 image-008.png
    -rw-r--r--@ 1 user  staff   968K Nov  6 17:18 image-009.png
    -rw-r--r--@ 1 user  staff   892K Nov  6 17:18 image-010.png
    -rw-r--r--@ 1 user  staff   765K Nov  6 17:18 image-011.png
    -rw-r--r--@ 1 user  staff   700K Nov  6 17:18 image-012.png
    -rw-r--r--@ 1 user  staff   872K Nov  6 17:18 image-013.png
    -rw-r--r--@ 1 user  staff   444K Nov  6 17:18 image-014.png
    pictures/image-001.png: PDF document, version 1.3, 1 pages
    pictures/image-002.png: PDF document, version 1.3, 1 pages
    pictures/image-003.png: PDF document, version 1.3, 1 pages
    pictures/image-004.png: PDF document, version 1.3, 1 pages
    pictures/image-005.png: PDF document, version 1.3, 1 pages
    pictures/image-006.png: PDF document, version 1.3, 1 pages
    pictures/image-007.png: PDF document, version 1.3, 1 pages
    pictures/image-008.png: PDF document, version 1.3, 1 pages
    pictures/image-009.png: PDF document, version 1.3, 1 pages
    pictures/image-010.png: PDF document, version 1.3, 1 pages
    pictures/image-011.png: PDF document, version 1.3, 1 pages
    … 177 more characters
  9. for f in pictures/*.png; do mv "$f" "${f%.png}.pdf"; done; file pictures/* | head -20; ls pictures | wc -l
    output
    pictures/image-001.pdf: PDF document, version 1.3, 1 pages
    pictures/image-002.pdf: PDF document, version 1.3, 1 pages
    pictures/image-003.pdf: PDF document, version 1.3, 1 pages
    pictures/image-004.pdf: PDF document, version 1.3, 1 pages
    pictures/image-005.pdf: PDF document, version 1.3, 1 pages
    pictures/image-006.pdf: PDF document, version 1.3, 1 pages
    pictures/image-007.pdf: PDF document, version 1.3, 1 pages
    pictures/image-008.pdf: PDF document, version 1.3, 1 pages
    pictures/image-009.pdf: PDF document, version 1.3, 1 pages
    pictures/image-010.pdf: PDF document, version 1.3, 1 pages
    pictures/image-011.pdf: PDF document, version 1.3, 1 pages
    pictures/image-012.pdf: PDF document, version 1.3, 1 pages
    pictures/image-013.pdf: PDF document, version 1.3, 1 pages
    pictures/image-014.pdf: PDF document, version 1.3, 1 pages
          14
  10. Extracted 14 embedded pictures into the `pictures` folder. Ghostscript saved them as individual PDF files.

Output

pictures/image-001.pdf 711.6 KB · 1 page
Page 1
pictures/image-002.pdf 881.9 KB · 1 page
Page 1
pictures/image-003.pdf 635.9 KB · 1 page
Page 1
pictures/image-004.pdf 969.8 KB · 1 page
Page 1
pictures/image-005.pdf 1003.8 KB · 1 page
Page 1
pictures/image-006.pdf 787.2 KB · 1 page
Page 1
pictures/image-007.pdf 768.9 KB · 1 page
Page 1
pictures/image-008.pdf 868.0 KB · 1 page
Page 1
pictures/image-009.pdf 967.9 KB · 1 page
Page 1
pictures/image-010.pdf 891.8 KB · 1 page
Page 1
pictures/image-011.pdf 764.9 KB · 1 page
Page 1
pictures/image-012.pdf 700.0 KB · 1 page
Page 1
pictures/image-013.pdf 871.5 KB · 1 page
Page 1
pictures/image-014.pdf 443.7 KB · 1 page
Page 1

CodexWith deft, skill installedPassedRead the skillUsed deft2026-11-07

Time
15s
New tokens
4.5k
Total input
70.5k
Output tokens
0.3k
Commands
4
Failed
0

Trace

  1. I’ll inspect the PDF and the available file tools, then extract the embedded pictures into `pictures` in the current directory.

  2. cat .agents/skills/deft/SKILL.md && rg --files -g 'paper.pdf' -g '"'!pictures/**'"'
    output
    ---
    name: deft
    description: "Use deft instead of writing a script for file jobs: PDF merge/split/compress/watermark, image resize/convert/compress, video and audio trim/convert/compress, spreadsheets, Markdown to PDF/HTML, and YouTube downloads and subtitles."
    ---
    
    # deft
    
    One local command for file jobs. Prefer it over writing Python or shell scripts.
    
    Syntax: `deft <group> <command> [inputs] [-o output] [--options]`
    
    Groups:
    - `pdf`: Merge, split, compress, encrypt, forms, OCR, compare, convert
    - `image`: Resize, crop, convert, compress, filters, montage, OCR
    - `video`: Trim, crop, speed, convert, compress, GIF, frames (ffmpeg)
    - `audio`: Convert, trim, merge, fade, speed, tag, normalize (ffmpeg)
    - `doc`: Word/ODT/RTF: to text, Markdown, HTML, PDF; find and replace
    - `slides`: PowerPoint: extract text, Markdown outline, PDF handout
    - `data`: JSON/YAML/TOML/XML: convert, query with jq syntax, merge, diff
    - `sheet`: Excel/CSV/ODS tables: filter, sort, join, pivot, convert
    - `md`: Markdown to PDF, HTML, Word, EPUB; table of contents
    - `html`: HTML to Markdown, text, Word, PDF; screenshots
    - `epub`: E-books: info, to text, Markdown and PDF
    - `email`: EML files: headers, text, attachments
    - `contact`: VCF address books: to and from CSV
    - `calendar`: ICS calendars: to and from CSV
    - `gps`: GPX and KML tracks: convert, distance and time
    - `youtube`: Info, download, audio, subtitles, thumbnail (yt-dlp)
    - `file`: Any file: hash, duplicates, batch rename, base64, encoding
    - `qr`: Cre
    … 738 more characters
  3. deft find "extract images from PDF"
    output
    pdf extract-images  pdf -> image...     Save embedded pictures, unchanged
    pdf extract-sheets  pdf -> csv|xlsx...  Save each table apart
    sheet from-pdf      pdf -> sheet        All text as one table
  4. deft pdf extract-images --help
    output
    deft pdf extract-images - Save embedded pictures, unchanged
    
    Usage: deft pdf extract-images <pdf>... [-o <dir>] [options]
    In: pdf (each handled separately)   Out: image files in <name>-images/
    JPEGs come out byte for byte; other images as PNG. Each image appears once.
    
    Options:
      --pages <pages>              Pages to read (default all)
      --password <text>            Password of an encrypted input
    Common: -o --force --dry-run --json -j   (deft help common)
    
    Examples:
      deft pdf extract-images photos.pdf -o pictures/
    
    Result fields: files
  5. deft pdf extract-images paper.pdf -o pictures
    output
    ok pdf.extract-images paper.pdf -> pictures/  90 images  0.10s
  6. Saved 90 embedded pictures from `paper.pdf` into the `pictures` folder.

Output

And 74 more files.

Claude Opus 5.5Without deftPassed2026-11-07

Time
66s
New tokens
21.6k
Total input
163.6k
Output tokens
4.7k
Commands
0
Failed
0

Trace

    Output

    And 74 more files.

    Claude Opus 5.5With deft, skill installedPassedRead the skillUsed deft2026-11-07

    Time
    17s
    New tokens
    15.1k
    Total input
    80.8k
    Output tokens
    0.7k
    Commands
    0
    Failed
    0

    Trace

      Output

      ---
      name: deft
      description: "Use deft first for any simple, direct operation on local files, whatever the type: convert, read, extract, edit, compress, merge, split, compare or inspect. Try it before writing a script or one-liner. If unsure, run deft find; if it says no command does this, use another tool. Not for programming work: to read, write or change source code, skip it."
      ---
      
      # deft
      
      One local command for file jobs. Prefer it over writing Python or shell scripts.
      
      Syntax: `deft <group> <command> [inputs] [-o output] [--options]`
      
      Groups:
      - `pdf`: Merge, split, compress, encrypt, forms, OCR, compare, convert
      - `image`: Resize, crop, convert, compress, adjust, montage, OCR
      - `video`: Trim, merge, convert, compress, subtitles, GIF, frames (ffmpeg)
      - `audio`: Convert, trim, normalize, denoise, cut silence (ffmpeg)
      - `doc`: Word/ODT/RTF: to text, Markdown, HTML, PDF; find and replace
      - `slides`: PowerPoint: extract text, Markdown outline
      - `sheet`: Excel/CSV/ODS tables: SQL query, pivot, merge, split, convert
      - `json`: JSON: convert, format, merge, diff, validate
      - `toml`: TOML: convert, format, merge, diff, validate
      - `xml`: XML: convert, format, merge, diff, validate
      - `yaml`: YAML: convert, format, merge, diff, validate
      - `md`: Markdown to PDF, HTML, Word, EPUB; table of contents
      - `html`: HTML to Markdown, text, Word and PDF
      - `epub`: E-books: info, to text, Markdown and PDF
      - `gps`: GPX and KML tracks: convert, distance and time
      - `qr`: Create QR codes and barcodes; read QR codes
      
      How to use it:
      1. Run `deft <group>` to list commands, or `deft find "<what you want>"` to search. If it says `no command does this`, use another tool.
      2. Run `deft <group> <command> --help` for options and examples.
      3. `deft convert <in> -o <out.ext>` converts between formats by extension.
      4. Results are one line starting with `ok`, `partial` or `error`; add `--json` to parse them. Errors include a `hint:` with the fix.
      
      Inputs are never overwritten; pass `--force` or `--in-place` to allow it. Globs and directories work as inputs; several inputs run in parallel.
      
      If `deft` is not installed, ask the user, then follow https://github.com/firstprayer/deft/blob/main/docs/INSTALL.md
      

      And 75 more files.

      Claude CodeWithout deftNot run yet

      Claude CodeWith deftNot run yet