typst / typst/typst

Ability to crop an image

Open
#3,147 14 comments 54 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature request visualize
Dominant language
Rust
Stars
56.1k
Forks
1.7k
Avg merge
3d 10h
Merged PRs (30d)
22

Description

Description

I suggest that the image() function should have a crop (or another name) argument that would crop the image. It could work a bit like the pad() function, for example

#image(
     "figure.jpg", 
     crop: 5pt,
)

would crop the image by 5pt from each side.

Or maybe it could be a separate function, like so

#crop(
     x: 5pt,
     top: 2pt,
     image("figure.jpg"),
)
Use Case

The ability to crop an image, or anything else, is useful on it's own, but when I'm writing a math paper and have a figure generated from python, the figures tend to have a white background spanning unnecessarily far. Im sure there will be other use cases tho

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the image() and pad() entry points and reading how their arguments affect rendered content. Determine how cropping should apply to image edges or other content, then establish the accepted API and verify that a cropped image matches the requested offsets. No specific files or tests are named in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
backend-api-design
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.