Automattic / Automattic/node-canvas

Black CMYK JEPGs in PDF with MIME data mode

Open
#1,183 0 comments 0 reactions 0 assignees View on GitHub
Bug Help wanted Images & Formats: JPEG
Dominant language
JavaScript
Stars
10.7k
Forks
1.2k
Avg merge
4d 8h
Merged PRs (30d)
1

Description

## Bug
I want to embed cmyk images in pdf using `img.dataMode = Image.MODE_MIME`. That should take the image and **embed it into pdf without any painting or editing**. But all cmyk images are black.

**JPG**
![img](https://user-images.githubusercontent.com/2387356/41710691-9a830d02-7546-11e8-8e48-8bda1d0f58de.jpg)

**PDF**
image

**Files**
[img.jpg.zip](https://github.com/Automattic/node-canvas/files/2122969/img.jpg.zip)
[out.pdf](https://github.com/Automattic/node-canvas/files/2122967/out.pdf)

Related issue https://github.com/Automattic/node-canvas/issues/425

## Steps to Reproduce
```js
const { createCanvas, Image } = require("canvas")
const { writeFileSync, readFileSync } = require("fs")

const img = new Image()
img.dataMode = Image.MODE_MIME
img.src = readFileSync("img.jpg")

const canvas = createCanvas(200, 200, "pdf")
const ctx = canvas.getContext("2d")
ctx.drawImage(img, 50, 50, 100, 100)
writeFileSync("out.pdf", canvas.toBuffer())
```

## Your Environment
* Version of node-canvas: 2.0.0-alpha.12
* Environment: node 10.1.0, macOS 10.13.5

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.