typst icon indicating copy to clipboard operation
typst copied to clipboard

Ability to crop an image

Open kuba375 opened this issue 5 months ago • 5 comments

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

kuba375 avatar Jan 07 '24 19:01 kuba375

This can already be achieved by wrapping the image in a block with negative inset and clip: true

Enivex avatar Jan 07 '24 19:01 Enivex

This can already be achieved by wrapping the image in a block with negative inset and clip: true

Is it possible to crop an image into a circle?

XcantloadX avatar Jan 11 '24 07:01 XcantloadX

Yes, you can add a radius to the box used during clipping:

box(pic, radius: 50%, clip: true)

ntjess avatar Jan 26 '24 23:01 ntjess

Is it possible to crop/clip an image with an arbitrary shape? (Our university's style guide is very particular about slopes…)

lumpiluk avatar Apr 11 '24 11:04 lumpiluk

That's not currently possible. You'd have to do that in another software separately.

laurmaedje avatar Apr 11 '24 21:04 laurmaedje