Skip to content

Commit 3ae8877

Browse files
Add .units("PixelsPerInch") to set proper DPI metadata in output images (#229)
This PR adds `.units("PixelsPerInch")` to the image generation process to make sure the output images include proper DPI metadata. Without this, the images don't reflect the density value set in the options. This can cause issues with OCR, printing, or any process that depends on DPI information. The change is small, safe, and compatible with both ImageMagick and GraphicsMagick.
1 parent dc4f173 commit 3ae8877

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/graphics.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export class Graphics {
4141
public gmBaseCommand(stream: fs.ReadStream, filename: string): gm.State {
4242
return this.gm(stream, filename)
4343
.density(this.density, this.density)
44+
.units("PixelsPerInch")
4445
.resize(this.width, this.height, this.preserveAspectRatio ? '^' : '!')
4546
.quality(this.quality)
4647
.compress(this.compression);

0 commit comments

Comments
 (0)