Merge pull request #7870 from dotCooCoo/fix/pdf-preserve-numbers-tagged-images

PDF export: Preserve Numbers converts tagged images from their profile
This commit is contained in:
BFlat
2026-11-16 08:11:02 +07:00
committed by GitHub
7 changed files with 231 additions and 33 deletions
File diff suppressed because one or more lines are too long
+3 -1
View File
@@ -143,7 +143,9 @@ impl Exporter<'_> {
let doc = self.doc;
let out = self.out.clone();
let profiles = out.source_profiles();
let to_srgb = out.image_srgb_intent().map(|intent| crate::images::ToSrgb { intent, sixteen_bit: self.sixteen_bit });
let then = out.converts_tagged_pixels().then_some(&*out);
let grey = out.converts_grey_images();
let to_srgb = out.image_srgb_intent().map(|intent| crate::images::ToSrgb { intent, sixteen_bit: self.sixteen_bit, then, grey });
let mut unconverted = false;
let img = doc.image_blob(im).filter(|_| !self.left_out.contains(key)).and_then(|blob| {
let cmyk_image = blob.is_cmyk();
+33 -16
View File
@@ -12,7 +12,9 @@
//! conversion leaves unchanged (an sRGB profile) keeps its JPEG data. A black-and-white image whose
//! converted levels are grey is compressed as greyscale. A colour image the Output settings also
//! convert to their destination ([`Pixels`]) goes from its profile to sRGB, then to the
//! destination; a grey one keeps its profile there, as grey pixels are not converted.
//! destination, and so does one converted from its profile to an RGB destination whose untagged
//! images keep their numbers (Preserve Numbers); a grey one keeps its profile there, as grey
//! pixels are not converted.
//!
//! CMYK images ([`ImageBlob::cmyk`]) stay CMYK: a CMYK JPEG already as asked is embedded as it is
//! when its numbers are kept; the others' ink amounts are resampled, converted when the Output
@@ -325,15 +327,23 @@ pub(crate) struct Recoded {
pub unconverted: bool,
}
/// How [`recode`] converts a gray or RGB image that carries an ICC profile to sRGB (Convert to
/// Destination, [`crate::output::ColorOut::image_srgb_intent`]): the destination when it is sRGB,
/// else the step before the image's [`Pixels`] conversion.
#[derive(Clone, Copy, Debug)]
pub(crate) struct ToSrgb {
/// How [`recode`] converts a gray or RGB image that carries an ICC profile to sRGB
/// ([`crate::output::ColorOut::image_srgb_intent`]): the destination when it is sRGB, else the
/// step before the image's [`Pixels`] conversion.
#[derive(Clone, Copy)]
pub(crate) struct ToSrgb<'a> {
/// The rendering intent of the conversion.
pub intent: Intent,
/// 16-bit samples may be written (PDF 1.5 and later).
pub sixteen_bit: bool,
/// The colour output whose [`crate::output::ColorOut::tagged_pixels`] then convert a colour
/// image converted from its profile, when other colour images are not converted (`recode`'s
/// `convert`): to an RGB destination whose untagged images keep their numbers (Preserve
/// Numbers). Its table is built when the first such image needs it.
pub then: Option<&'a crate::output::ColorOut>,
/// Gray images are converted too: with an sRGB destination
/// ([`crate::output::ColorOut::converts_grey_images`]). In the others they keep their profile.
pub grey: bool,
}
/// What happens to the ICC profile a gray or RGB image carries
@@ -521,13 +531,15 @@ fn resample_channels(img: DynamicImage, r: &Rule, (w, h): (u32, u32)) -> Dynamic
/// Encoded image `bytes` placed `size` points wide and high, as the Compression settings `c` ask:
/// resampled when its resolution is above the threshold, compressed with ZIP or JPEG, its colours
/// converted by `convert` (colour images). Pixels that keep their colours keep the ICC profile
/// they carry when `profiles` keeps it ([`SourceProfiles::Keep`]); with `to_srgb`, pixels in a gray or RGB profile other than sRGB are converted from it to sRGB
/// instead ([`ToSrgb`]), and colour ones then by `convert`; grey ones that `convert` leaves as
/// they are keep their profile. `interpolate` lets viewers smooth it. An image that can't be
/// decoded is kept as it is, with a warning when its pixels were to be converted to sRGB. When
/// `convert` was to convert its colors, it is [`Recoded::unconverted`] if its header can't be read
/// (it may be in color) or its pixels are beyond the decode allowance; a color image whose pixel
/// data can't be read is not.
/// they carry when `profiles` keeps it ([`SourceProfiles::Keep`]); with `to_srgb`, pixels in a
/// gray or RGB profile other than sRGB are converted from it to sRGB instead ([`ToSrgb`]), and
/// colour ones then by `convert`, or without it by the conversion `to_srgb` gives
/// ([`ToSrgb::then`]); grey ones keep their profile unless the destination is sRGB
/// ([`ToSrgb::grey`]). `interpolate` lets viewers smooth it. An image that can't be decoded is
/// kept as it is, with a warning when its pixels were to be converted to sRGB. When `convert`
/// was to convert its colors, it is [`Recoded::unconverted`] if its header can't be read (it may
/// be in color) or its pixels are beyond the decode allowance; a color image whose pixel data
/// can't be read is not.
pub(crate) fn recode(
bytes: &[u8],
size: (f64, f64),
@@ -545,8 +557,9 @@ pub(crate) fn recode(
use ExtendedColorType as T;
let grey = matches!(decoder.original_color_type(), T::L1 | T::La1 | T::L2 | T::La2 | T::L4 | T::La4 | T::L8 | T::La8 | T::L16 | T::La16);
// Pixels in a profile they are converted from are decoded, whatever the Compression settings.
// Grey pixels, which `convert` leaves as they are, keep their profile when it converts.
let to_srgb = to_srgb.filter(|_| !(grey && convert.is_some()));
// Grey pixels keep their profile unless the destination is sRGB ([`ToSrgb::grey`]).
let then = to_srgb.and_then(|t| t.then);
let to_srgb = to_srgb.filter(|t| !grey || t.grey);
// Converted to the destination as sRGB, as before, when the profile can't be read.
let mut note = None;
let source = match to_srgb.and_then(|t| Some((source_profile(bytes, if grey { *b"GRAY" } else { *b"RGB " })?, t))) {
@@ -589,6 +602,8 @@ pub(crate) fn recode(
Ok(img) => img,
Err(limited) => return Recoded { unconverted: limited && convert.is_some(), ..keep },
};
// Converted from its profile: then by `convert`, else by the conversion `to_srgb` gives.
let mut from_profile = false;
if let Some((p, t)) = &source {
let srgb = match into_srgb(img, p, t.intent) {
Some(s) => Some(s),
@@ -606,8 +621,9 @@ pub(crate) fn recode(
if kind == Kind::Mono && !bilevel(&srgb) {
(kind, rule) = (Kind::Gray, self::rule(c, Kind::Gray));
}
from_profile = true;
// Written as it is only when nothing converts it further.
let as_is = kept(&rule, dims, size, jpeg) && convert.is_none();
let as_is = kept(&rule, dims, size, jpeg) && convert.is_none() && then.is_none();
// A JPEG kept as JPEG whose samples the conversion leaves unchanged (an sRGB
// profile): its JPEG data, without the profile (and, with `Remove`, without its
// segments: encoded again when those can't be taken out).
@@ -632,6 +648,7 @@ pub(crate) fn recode(
},
};
}
let convert = if from_profile { convert.or_else(|| then.and_then(crate::output::ColorOut::tagged_pixels)) } else { convert };
// Pixels that keep their colours keep the profile they are in; converted ones are in the
// destination's.
let want = if kind == Kind::Color { *b"RGB " } else { *b"GRAY" };
+50 -7
View File
@@ -14,7 +14,10 @@
//! that carries an ICC profile is converted from it to sRGB with the same intent and written
//! without it ([`ColorOut::image_srgb_intent`]); with `destination` and a destination its
//! pixels are converted to (CMYK, another RGB space), a colour image is converted from its
//! profile to sRGB and then to the destination. Without conversion it keeps its profile. The
//! profile to sRGB and then to the destination. With `preserveNumbers` (and PDF/X-1a), which
//! keeps the numbers of untagged colours only, such an image is converted from its profile
//! whatever the destination: to sRGB, and then to a CMYK or other RGB destination
//! ([`ColorOut::tagged_pixels`]). Without conversion it keeps its profile. The
//! destination is a profile name; empty, the document's profile for its colour mode.
//! - Profiles ([`ProfileInclusion`]): with `all`, with `destination`, and with `taggedSource` on a
//! document that was assigned profiles, colours are written in ICC-based colour spaces: CMYK
@@ -84,6 +87,9 @@ pub(crate) struct ColorOut {
pub srgb_note: Option<String>,
/// The image transform, built when the first image needs it.
pixels: OnceLock<Option<Pixels>>,
/// The transform of images converted from their profile, when it isn't `pixels`
/// ([`Self::tagged_pixels`]).
tagged_pixels: OnceLock<Option<Pixels>>,
/// The CMYK image transform, built when the first CMYK image needs it.
cmyk_pixels: OnceLock<Option<CmykPixels>>,
intent: Intent,
@@ -128,6 +134,7 @@ impl Default for ColorOut {
cmyk_profile,
srgb_note: None,
pixels: OnceLock::new(),
tagged_pixels: OnceLock::new(),
cmyk_pixels: OnceLock::new(),
intent,
catalog: None,
@@ -361,13 +368,49 @@ impl ColorOut {
/// The intent a gray or RGB image that carries an ICC profile is converted from it to sRGB
/// with ([`crate::images::recode`]): the colour settings' intent, with Convert to Destination
/// and an sRGB destination, also when the document's RGB space is sRGB, or a destination
/// colour images' pixels are then converted to ([`Self::pixels`]: CMYK, another RGB space).
/// `None` otherwise, Preserve Numbers and an RGB destination that is the document's own RGB
/// profile (which leaves RGB colours and RGB images as they are) included: such an image
/// keeps its profile, or its numbers are converted as sRGB ones.
/// colour images' pixels are then converted to ([`Self::pixels`]: CMYK, another RGB space);
/// and with Preserve Numbers (and PDF/X-1a's own conversion), whatever the destination, as
/// only untagged colours of the destination's model keep their numbers. The pixels are then
/// converted by [`Self::tagged_pixels`]. `None` otherwise, an RGB destination that is the
/// document's own RGB profile with Convert to Destination (which leaves RGB colours and RGB
/// images as they are) included: such an image keeps its profile.
pub(crate) fn image_srgb_intent(&self) -> Option<Intent> {
let d = self.dest.as_ref().filter(|d| d.destination)?;
((d.model == Model::Rgb && d.srgb) || self.pixels().is_some()).then_some(self.intent)
let d = self.dest.as_ref()?;
let rgb = d.model == Model::Rgb && (d.srgb || !d.destination);
(rgb || self.pixels().is_some()).then_some(self.intent)
}
/// Are gray images that carry an ICC profile converted from it to sRGB grays too
/// ([`Self::image_srgb_intent`])? Only with an sRGB destination; in the others, RGB tagged as
/// sRGB included, grey pixels are not converted and keep their profile.
pub(crate) fn converts_grey_images(&self) -> bool {
self.dest.as_ref().is_some_and(|d| d.model == Model::Rgb && d.srgb)
}
/// The destination a colour image converted from its ICC profile to sRGB
/// ([`Self::image_srgb_intent`]) is then converted to when other colour images are not
/// ([`Self::pixels`]): with Preserve Numbers, an RGB destination other than sRGB, whose
/// untagged RGB images keep their numbers (unless RGB is tagged as sRGB).
fn tagged_rgb_dest(&self) -> Option<&Dest> {
self.dest.as_ref().filter(|d| !d.destination && d.model == Model::Rgb && !d.srgb && !self.tagged)
}
/// Are colour images converted from their ICC profile then converted by
/// [`Self::tagged_pixels`]?
pub(crate) fn converts_tagged_pixels(&self) -> bool {
self.tagged_rgb_dest().is_some()
}
/// How a colour image converted from its ICC profile to sRGB is then converted into that
/// destination's RGB space ([`Self::converts_tagged_pixels`]), built when the first such image
/// needs it; `None` when there is no such destination.
pub(crate) fn tagged_pixels(&self) -> Option<&Pixels> {
self.tagged_pixels
.get_or_init(|| {
let d = self.tagged_rgb_dest()?;
Some(Pixels::Rgb(Box::new(ProofLut::build(|rgb| d.cms.srgb_to_rgb(rgb)))))
})
.as_ref()
}
/// The CMYK profile CMYK image `blob` is tagged with ([`crate::images::cmyk_icc`]): the one it
+128 -2
View File
@@ -282,7 +282,9 @@ fn a_color_image_beyond_the_allowance_for_a_conversion_is_unconverted() {
let settings: PdfSettings = serde_json::from_value(json!({"output": {"conversion": "destination", "destination": GENERIC_CMYK}})).unwrap();
let out = crate::output::ColorOut::new(&d, &settings).unwrap();
assert!(out.pixels().is_some());
let to_srgb = out.image_srgb_intent().map(|intent| crate::images::ToSrgb { intent, sixteen_bit: false });
let then = out.converts_tagged_pixels().then_some(&out);
let grey = out.converts_grey_images();
let to_srgb = out.image_srgb_intent().map(|intent| crate::images::ToSrgb { intent, sixteen_bit: false, then, grey });
assert!(to_srgb.is_some());
let c: CompressionSettings = serde_json::from_value(json!({})).unwrap();
let half = |mut bytes: Vec<u8>| {
@@ -898,7 +900,7 @@ fn convert_to_srgb_converts_tagged_images_from_their_profile() {
png
};
let c: CompressionSettings = serde_json::from_value(json!({})).unwrap();
let srgb_out = Some(crate::images::ToSrgb { intent: Intent::RelativeColorimetric, sixteen_bit: true });
let srgb_out = Some(crate::images::ToSrgb { intent: Intent::RelativeColorimetric, sixteen_bit: true, then: None, grey: true });
for (what, png) in [("RGB", declared(&colour(), &p3)), ("gray", declared(&colour().grayscale(), &gray))] {
let keep = crate::images::SourceProfiles::Keep;
let r = crate::images::recode(&png, (100.0, 100.0), &c, false, None, keep, srgb_out);
@@ -1103,3 +1105,127 @@ fn convert_to_destination_converts_tagged_images_from_their_profile() {
let as_srgb = converted_samples(&img, to_cmyk);
assert!(image_samples(&r.bytes).first().is_some_and(|s| samples_close(s, &as_srgb, false, 1)), "unread profile: converted as sRGB");
}
/// With Preserve Numbers, an RGB image that carries an ICC profile is converted from that profile
/// whatever the destination, while an untagged one keeps its numbers in an RGB destination (and
/// converts from sRGB to a CMYK one, as before): to Generic CMYK, sRGB, Wide Gamut RGB, and Wide
/// Gamut RGB that is also the document's RGB profile, and in PDF/X-1a, which converts the same way.
/// A gray image keeps its profile, except in an sRGB destination, where it is converted to sRGB
/// grays. An RGB profile the CMS can't read leaves the image as it is in an RGB destination, and
/// its numbers converted as sRGB ones to a CMYK destination, with a warning.
#[test]
fn preserve_numbers_converts_tagged_images_from_their_profile() {
use vectorcraft_color::cms::{self, ColorSettings, DISPLAY_P3, GENERIC_CMYK, Intent, SRGB, WIDE_GAMUT_RGB, icc_bytes};
let intent = Intent::RelativeColorimetric;
let settings_with =
|rgb: &str| std::sync::Arc::new(cms::Cms::new(&ColorSettings { intent, rgb: rgb.into(), ..ColorSettings::default() }).unwrap());
let (active, own) = (settings_with(SRGB), settings_with(WIDE_GAMUT_RGB));
let mut p3 = icc_bytes(DISPLAY_P3).unwrap().to_vec();
p3[8..12].copy_from_slice(&[4, 0x20, 0, 0]);
let p3_profile = cms::IccProfile::from_bytes(None, &p3).unwrap();
let from_p3 = |rgb: [u8; 3]| p3_profile.to_srgb(&rgb.map(|v| f32::from(v) / 255.0), intent).unwrap().map(|v| (v * 255.0).round() as u8);
let img = colour_blocks();
let tagged_png = doc(tagged(&img, &p3, ImageFormat::Png), "image/png");
let untagged_png = doc(encoded(img.clone(), ImageFormat::Png), "image/png");
let device = |space: &str| vec![Written { space: space.into(), icc: None, bits: 8, filter: "FlateDecode".into(), smask: false }];
let cmyk = cms::Cms::new(&ColorSettings { intent, cmyk: GENERIC_CMYK.into(), ..ColorSettings::default() }).unwrap();
let cmy = cms::ProofLut::build(|rgb| {
let v = cmyk.srgb_to_cmyk(rgb, intent);
[v[0], v[1], v[2]]
});
let black = cms::ProofLut::build(|rgb| [cmyk.srgb_to_cmyk(rgb, intent)[3], 0.0, 0.0]);
let wide_lut = cms::ProofLut::build(|rgb| own.srgb_to_rgb(rgb));
let to_cmyk = |rgb: [u8; 3]| [cmy.apply8(rgb).as_slice(), &black.apply8(rgb)[..1]].concat();
let to_wide = |rgb: [u8; 3]| wide_lut.apply8(rgb).to_vec();
let to_srgb = |rgb: [u8; 3]| rgb.to_vec();
type ToDest<'a> = &'a dyn Fn([u8; 3]) -> Vec<u8>;
// Each case: what, the color settings, the export settings, the space images are written in,
// how an sRGB pixel converts to the destination, and whether untagged images keep their numbers.
type Case<'a> = (&'a str, &'a std::sync::Arc<cms::Cms>, Value, &'a str, ToDest<'a>, bool);
let cases: [Case<'_>; 5] = [
("CMYK", &active, json!({"output": {"conversion": "preserveNumbers", "destination": GENERIC_CMYK}}), "DeviceCMYK", &to_cmyk, false),
("sRGB", &active, json!({"output": {"conversion": "preserveNumbers", "destination": SRGB}}), "DeviceRGB", &to_srgb, true),
("Wide Gamut", &active, json!({"output": {"conversion": "preserveNumbers", "destination": WIDE_GAMUT_RGB}}), "DeviceRGB", &to_wide, true),
("own RGB", &own, json!({"output": {"conversion": "preserveNumbers", "destination": WIDE_GAMUT_RGB}}), "DeviceRGB", &to_wide, true),
(
"PDF/X-1a",
&active,
json!({"standard": "pdfX1a", "compatibility": "1.3", "output": {"destination": GENERIC_CMYK}}),
"DeviceCMYK",
&to_cmyk,
false,
),
];
for (what, color, settings, space, to_dest, keeps) in cases {
let export = |d: &Document| {
let mut s: PdfSettings = serde_json::from_value(settings.clone()).unwrap();
s.compression.compress_text = false;
let r = cms::with_active((*color).clone(), || export_with_report(d, &PdfOptions { settings: s, ..Default::default() })).unwrap();
assert!(r.warnings.is_empty(), "{what}: {:?}", r.warnings);
if what == "PDF/X-1a" {
crate::pdfx::verify(&r.bytes, Standard::PdfX1a).unwrap_or_else(|e| panic!("{what}: {e}"));
}
(image_spaces(&r.bytes), image_samples(&r.bytes))
};
let (spaces, samples) = export(&tagged_png);
assert_eq!(spaces, device(space), "{what}: tagged");
let want = converted_samples(&img, |rgb| to_dest(from_p3(rgb)));
let as_numbers = converted_samples(&img, to_dest);
assert!(
samples.len() == 1 && samples_close(&samples[0], &want, false, 1),
"{what}: converted from the profile, {}",
max_diff(&samples[0], &want)
);
assert!(!samples_close(&samples[0], &as_numbers, false, 8), "{what}: not converted as its numbers");
let (spaces, samples) = export(&untagged_png);
assert_eq!(spaces, device(space), "{what}: untagged");
let untagged = if keeps { img.to_rgb8().into_raw() } else { as_numbers };
assert!(samples.len() == 1 && samples_close(&samples[0], &untagged, false, 1), "{what}: untagged, {}", max_diff(&samples[0], &untagged));
}
// With RGB colours ICC-tagged as sRGB, the tagged image is written as its sRGB samples, in an
// ICC-based colour space with the sRGB profile.
let settings = json!({"output": {"conversion": "preserveNumbers", "destination": WIDE_GAMUT_RGB, "profiles": "all"}});
let (spaces, pdf) = cms::with_active(active.clone(), || export_images(&tagged_png, settings));
let is_srgb = |icc: &[u8]| {
let p = cms::IccProfile::from_bytes(None, icc).unwrap();
[[0.2, 0.5, 0.9], [0.9, 0.1, 0.4]].iter().all(|v| p.to_srgb(v, intent).unwrap().iter().zip(v).all(|(a, b)| (a - b).abs() < 0.01))
};
assert!(spaces.len() == 1 && spaces[0].space == "ICCBased" && spaces[0].icc.as_deref().is_some_and(is_srgb), "tagged as sRGB: {spaces:?}");
let samples = image_samples(&pdf);
let want = converted_samples(&img, |rgb| from_p3(rgb).to_vec());
assert!(samples.len() == 1 && samples_close(&samples[0], &want, false, 1), "tagged as sRGB, {}", max_diff(&samples[0], &want));
// A gray image keeps its gray profile, in a CMYK and in an RGB destination, and in an RGB one
// with RGB colours ICC-tagged as sRGB (`all` profiles, PDF/A-2b).
let gray = gray_profile(&[0x01CD]);
let gray_doc = doc(tagged(&colour().grayscale(), &gray, ImageFormat::Tiff), "image/tiff");
for (what, settings) in [
(GENERIC_CMYK, json!({"output": {"conversion": "preserveNumbers", "destination": GENERIC_CMYK}})),
(WIDE_GAMUT_RGB, json!({"output": {"conversion": "preserveNumbers", "destination": WIDE_GAMUT_RGB}})),
("all profiles", json!({"output": {"conversion": "preserveNumbers", "destination": WIDE_GAMUT_RGB, "profiles": "all"}})),
("PDF/A-2b", json!({"standard": "pdfA2b", "output": {"conversion": "preserveNumbers", "destination": WIDE_GAMUT_RGB}})),
] {
let (spaces, _) = cms::with_active(active.clone(), || export_images(&gray_doc, settings));
assert!(spaces.len() == 1 && spaces[0].space == "ICCBased" && spaces[0].icc.as_deref() == Some(gray.as_slice()), "gray, {what}: {spaces:?}");
}
// In an sRGB destination it is converted to sRGB grays and written without it.
let settings = json!({"output": {"conversion": "preserveNumbers", "destination": SRGB}});
let (spaces, _) = cms::with_active(active.clone(), || export_images(&gray_doc, settings));
assert!(spaces.len() == 1 && spaces[0].space == "DeviceGray" && spaces[0].icc.is_none(), "gray, sRGB: {spaces:?}");
// A profile the CMS can't read: the image keeps it and its numbers in an RGB destination, and
// its numbers are converted as sRGB ones to a CMYK destination, with a warning each.
let unread = icc_profile(b"RGB ", 600);
let unread_doc = doc(tagged(&img, &unread, ImageFormat::Png), "image/png");
let unread_export = |destination: &str| {
let mut s: PdfSettings = serde_json::from_value(json!({"output": {"conversion": "preserveNumbers", "destination": destination}})).unwrap();
s.compression.compress_text = false;
cms::with_active(active.clone(), || export_with_report(&unread_doc, &PdfOptions { settings: s, ..Default::default() })).unwrap()
};
let r = unread_export(WIDE_GAMUT_RGB);
assert!(r.warnings.iter().any(|w| w.contains("the image keeps it")), "{:?}", r.warnings);
let spaces = image_spaces(&r.bytes);
assert!(spaces.len() == 1 && spaces[0].space == "ICCBased" && spaces[0].icc.as_deref() == Some(unread.as_slice()), "unread profile: {spaces:?}");
let r = unread_export(GENERIC_CMYK);
assert!(r.warnings.iter().any(|w| w.contains("converted to the destination as sRGB")), "{:?}", r.warnings);
let as_srgb = converted_samples(&img, to_cmyk);
assert!(image_samples(&r.bytes).first().is_some_and(|s| samples_close(s, &as_srgb, false, 1)), "unread profile, CMYK: converted as sRGB");
}
+15 -6
View File
@@ -5992,12 +5992,21 @@ are converted to, an RGB image that carries an ICC profile is converted from tha
and then to the destination, instead of having its numbers read as sRGB (a profile the color engine can't read leaves
them read as sRGB, with a warning); a gray image keeps its profile, as gray is not converted. An RGB destination other
than sRGB that is the document's own RGB profile leaves RGB colors and RGB images as they are, so a tagged RGB image keeps its profile
there. Any other image whose colors are converted (a CMYK image, or an RGB image going to a CMYK destination or to an
RGB one other than sRGB) but whose pixels are more than VectorCraft decodes or can't be written that way is left out with
the warning "an image couldn't be converted to the Output destination and is missing from the picture", rather than
written in its own colors. One whose pixel data can't be read is left out with the warning "an image couldn't be decoded
and is missing from the picture", as without a conversion.
`preserveNumbers` still reads an image's numbers as sRGB. The destination is any profile `edit.colorSettings` lists (default: the document's
there.
`preserveNumbers` (and PDF/X-1a, which converts the same way) keeps the numbers of untagged content only: an RGB image
that carries an ICC profile is converted from that profile to sRGB with the same intent, and then to a CMYK or other
RGB destination, the document's own RGB profile included (written as sRGB when colours are ICC-tagged), while an untagged RGB image keeps its numbers in an RGB
destination and converts from sRGB to a CMYK one. A gray image that carries one is converted to sRGB grays in an
sRGB destination and keeps its profile in the others, and a profile the color engine can't
read leaves the image as it is in an RGB destination, with a warning, and its numbers read as sRGB in a CMYK one.
In both modes, any other image whose colors are converted (a CMYK image, an RGB image going to a CMYK destination, or
with `destination` an RGB image going to an RGB one other than sRGB) but whose pixels are more than VectorCraft decodes
or can't be written that way is left out with the warning "an image couldn't be converted to the Output destination and
is missing from the picture", rather than written in its own colors. One whose pixel data can't be read is left out with
the warning "an image couldn't be decoded and is missing from the picture", as without a conversion. A tagged RGB image
that `preserveNumbers` converts in an RGB destination but whose pixels can't be decoded keeps its profile, with a
warning, as with `destination` and an sRGB destination.
The destination is any profile `edit.colorSettings` lists (default: the document's
for its colour mode). `profiles` (`all`, `destination`, or `taggedSource` for a document assigned profiles with
`edit.assignProfile`) writes colours in ICC-based spaces with their profiles embedded: CMYK with the destination's or
the document's CMYK profile, RGB as sRGB, grey with the sRGB tone curve (PDF/A, PDF/X-3 and PDF/X-4 files are
+1
View File
@@ -1973,6 +1973,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur
- PDF export writes a stored gray or RGB TIFF in an `ICCBased` color space that holds the gray or RGB profile of its tag 34675, at 16 bits a sample from PDF 1.5 on and 8 before, with its alpha as a soft mask only when some pixel is not opaque ([ISO 32000-1, §8.6.5.5](https://opensource.adobe.com/dc-acrobat-sdk-docs/pdfstandards/PDF32000_2008.pdf#page=157)). A gray or RGB image, a PNG included, that the Compression settings resample or compress with JPEG keeps its profile too, and gray pixels in an RGB profile stay RGB. Pixels the Output settings convert, a profile whose color space differs from the samples', and a malformed profile, a PNG's or JPEG's kept as it is included, are written without it; such a JPEG keeps its JPEG data. PDF/X-1a allows no ICC-based color spaces, so there a gray image with a gray profile, kept as it is, resampled or compressed with JPEG, is written in DeviceGray without the profile, a JPEG kept as JPEG with its JPEG data unchanged, and RGB images are converted to CMYK as before. CMYK images are unchanged (`crates/pdf/src/tests/compression.rs`).
- PDF export with Output › Convert to Destination and an sRGB destination converts a gray or RGB image that carries an ICC profile from that profile to sRGB, with the color settings' rendering intent, and writes it without the profile, as the conversion applies to every color ([PDF options](https://helpx.adobe.com/illustrator/using/pdf-options.html)): 8-bit and 16-bit TIFFs (16 bits a sample from PDF 1.5 on when not resampled or recompressed), PNGs, JPEGs (kept as JPEG) and resampled images. A JPEG in an sRGB profile keeps its JPEG data, a black-and-white image whose converted levels are gray is written as grayscale, and without conversion every image keeps its profile. An image whose profile the color engine can't read, or whose pixels can't be decoded, is not converted: it keeps its profile, with a warning (`crates/pdf/src/tests/compression.rs`).
- PDF export with Output › Convert to Destination and a CMYK destination, or an RGB destination other than sRGB that images are converted to, converts an RGB image that carries an ICC profile from that profile to sRGB and then to the destination, with the color settings' rendering intent, instead of reading its numbers as sRGB ([PDF options](https://helpx.adobe.com/illustrator/using/pdf-options.html)). An untagged image converts from sRGB as before, a gray image keeps its profile, and a profile the color engine can't read leaves the numbers read as sRGB, with a warning. An RGB destination other than sRGB that is the document's own RGB profile leaves RGB colors and RGB images as they are, so a tagged RGB image keeps its profile there (`convert_to_destination_converts_tagged_images_from_their_profile` in `crates/pdf/src/tests/compression.rs`).
- PDF export with Output › Convert to Destination (Preserve Numbers), and PDF/X-1a, keeps the numbers of untagged content only, as the option describes ([PDF options](https://helpx.adobe.com/illustrator/using/pdf-options.html)): an RGB image that carries an ICC profile is converted from that profile to sRGB with the color settings' rendering intent, and then to a CMYK or other RGB destination, the document's own RGB profile included, while an untagged RGB image keeps its numbers in an RGB destination. A gray image is converted to sRGB grays in an sRGB destination and keeps its profile in the others, and a profile the color engine can't read leaves the image as it is in an RGB destination, with a warning (`preserve_numbers_converts_tagged_images_from_their_profile` in `crates/pdf/src/tests/compression.rs`).
- SVG import shows a raster `<image>` whose EXIF orientation or TIFF Orientation tag turns or flips it upright, linked or as a data URL, and inside an SVG shown as an image: the pixels are stored turned, the width and height swap, and the `<image>` box fits the turned image under `preserveAspectRatio`, as CSS `image-orientation: from-image` describes (<https://www.w3.org/TR/css-images-3/#the-image-orientation>). A turned CMYK JPEG or TIFF keeps its inks as a CMYK TIFF, as does a CMYK TIFF that is not turned. TIFF data URLs (`image/tiff`, or untyped TIFF bytes) are read, and TIFFs with an alpha or other extra channel, CCITT Group 3 TIFFs and CMYK TIFFs stored one plane per ink are read as Open and Place read them. The pixels are decoded within the decode allowance, and a TIFF claiming more strips or tiles than the decoder can count is refused before it is decoded (`crates/svg/tests/it/image_orientation.rs`).
- An image that SVG import stores again, as PNG or as a CMYK TIFF, keeps the resolution its PNG, JPEG, TIFF, WebP or BMP file declares, as Open and Place keep it: in a PNG `pHYs` chunk (<https://www.w3.org/TR/png-3/#11pHYs>) or the TIFF's resolution tags, with the horizontal and vertical values swapped when the image turns a quarter. An image that declares no resolution is stored without one (`a_turned_raster_keeps_its_resolution`, `an_upright_tiff_keeps_its_resolution` and `a_cmyk_tiff_keeps_its_resolution_turned_or_not` in `crates/svg/tests/it/image_orientation.rs`).
- An image that SVG import stores again as PNG keeps the ICC profile its TIFF, PNG, JPEG or WebP file carries, as Open and Place keep it, as a PNG `iCCP` chunk, when the profile's color space is the stored samples': gray for gray samples, RGB for RGB ones (<https://www.w3.org/TR/png-3/#11iCCP>). By default, SVG reads an image's colors in the profile built into the image (<https://www.w3.org/TR/SVG11/color.html#ColorProfileProperty>). A profile of another color space, one too short to be a profile, and the profile of a TIFF whose pixels its own reader converts to RGBA (one with an alpha or other extra channel, or CCITT Group 3) are left out, and the image is still imported (`a_raster_written_again_as_png_keeps_its_icc_profile` in `crates/svg/tests/it/image_orientation.rs`).