IRONSOFTWAREHOME

PDF to PNG Red-Tint on macOS in IronPDF for Node.js

Curtis Chau
Curtis Chau
Updated: June 10, 2026

When rasterizing a PDF to PNG on macOS using IronPDF for Node.js, the output image has incorrect colors. A QR code that appears black in the source PDF renders red in the exported PNG.

A color-channel mapping error in the macOS PDF-to-image rasterization pipeline causes the output to use an incorrect channel order, producing the red tint.

Solution

Rasterize to JPG instead of PNG, then use sharp to convert the JPG to a grayscale PNG. This sidesteps the macOS color-channel mapping issue.

Install sharp:

npm install sharp
SHELL

Rasterize to JPG, then convert to PNG:

import { PdfDocument, ImageType } from "@ironsoftware/ironpdf";
import sharp from "sharp";

const pdf = await PdfDocument.fromFile("input.pdf");

const [jpgPage] = await pdf.rasterizeToImageBuffers({
    fromPages: 0,
    imageType: ImageType.JPG,
});

const pngBuffer = await sharp(jpgPage)
    .flatten({ background: "#ffffff" })
    .grayscale()
    .threshold(160)
    .png()
    .toBuffer();
TypeScript

Adjust the threshold value between 120 and 200 based on the QR code contrast in your PDF. This post-processing step is safe for QR codes because they are binary: black cells on a white background. A grayscale conversion loses nothing for QR codes.

Curtis Chau
Technical Writer

Curtis Chau holds a Bachelor’s degree in Computer Science (Carleton University) and specializes in front-end development with expertise in Node.js, TypeScript, JavaScript, and React. Passionate about crafting intuitive and aesthetically pleasing user interfaces, Curtis enjoys working with modern frameworks and creating well-structured, visually appealing manuals.

...
Read More

Ready to Get Started?

Version:2026.8just released

Get your free 30-day Trial Key instantly.
No credit card or account creation required
Node.js Module Download for PDF
Install with npm

Version: 2026.8

  1. Download and install Node.js 12+.
  2. Execute the above command in the terminal.

Licenses from $999

Key in blue circle

Get your free 30-day Trial Key instantly.

Your trial license will be sent to your email address

No limitations. 100% unlocked. No credit card.

OR
bullet_checkedNo credit card or account creation requiredNo limitations. 100% unlocked. No credit card.
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronPDF
Book your free Live Demo
Booking Badge

Trusted by Millions of Engineers Worldwide

Iron Software's customer logos
Get Your No-Obligation Consult
Complete the form below or email sales@ironsoftware.com
Your details will always be kept confidential.
Trusted by Millions of Engineers Worldwide
Iron Software's customer logos
Get your free 30-day Trial Key instantly.
No credit card or account creation required
Node.js Module Download for PDF
Install with npm

Version: 2026.8

  1. Download and install Node.js 12+.
  2. Execute the above command in the terminal.

Licenses from $999