comparison mupdf-source/docs/examples/reconvert-cmyk.js @ 2:b50eed0cc0ef upstream

ADD: MuPDF v1.26.7: the MuPDF source as downloaded by a default build of PyMuPDF 1.26.4. The directory name has changed: no version number in the expanded directory now.
author Franz Glasner <fzglas.hg@dom66.de>
date Mon, 15 Sep 2025 11:43:07 +0200
parents
children
comparison
equal deleted inserted replaced
1:1d09e1dec1d9 2:b50eed0cc0ef
1 // Read an image that was converted to RGB from CMYK without color management,
2 // and re-convert it using a better CMYK profile.
3
4 "use strict"
5
6 if (scriptArgs.length != 2) {
7 print("usage: mutool run recolor-cmyk.js input.png output.png")
8 quit()
9 }
10
11 var pixmap = new mupdf.Image(scriptArgs[0]).toPixmap()
12 mupdf.disableICC()
13 pixmap = pixmap.convertToColorSpace(mupdf.ColorSpace.DeviceCMYK)
14 mupdf.enableICC()
15 pixmap = pixmap.convertToColorSpace(mupdf.ColorSpace.DeviceRGB)
16 if (scriptArgs[1].match(/\.jpg/))
17 pixmap.saveAsJPEG(scriptArgs[1], 100)
18 else
19 pixmap.saveAsPNG(scriptArgs[1])