PDF export: Preserve Numbers converts tagged images from their profile

With Output › Convert to Destination (Preserve Numbers), and in PDF/X-1a,
which converts the same way, a gray or RGB image that carries an ICC
profile had its numbers read as sRGB: converted as sRGB to a CMYK
destination, and kept as they were in an RGB one. Preserve Numbers keeps
the numbers of untagged content only, so such an image is now converted
from its profile to sRGB with the color settings' intent, and then to a
CMYK or other RGB destination, the document's own RGB profile included.

- An untagged RGB image keeps its numbers in an RGB destination and
  converts from sRGB to a CMYK one, as before.
- A gray image is converted to sRGB grays in an sRGB destination and
  keeps its profile in the others.
- With RGB colors ICC-tagged as sRGB, the image is written as sRGB.
- A profile the color engine can't read leaves the image as it is in an
  RGB destination, and its numbers read as sRGB in a CMYK one, with a
  warning each.
- The table for an RGB destination is built only when the first tagged
  image needs it.
This commit is contained in:
dotCooCoo
2026-11-15 07:28:29 -08:00
parent 3075889f0c
commit 411310a757
7 changed files with 199 additions and 21 deletions
File diff suppressed because one or more lines are too long
+2 -1
View File
@@ -139,7 +139,8 @@ impl Exporter<'_> {
let doc = self.doc;
let out = self.out.clone();
let profiles = !out.standard.cmyk_only();
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 to_srgb = out.image_srgb_intent().map(|intent| crate::images::ToSrgb { intent, sixteen_bit: self.sixteen_bit, then });
let img = doc.image_blob(im).filter(|_| !self.left_out.contains(key)).and_then(|blob| {
let cmyk_image = blob.is_cmyk();
if !cmyk_image && self.convert && doc.color_mode == vectorcraft_doc::ColorMode::Cmyk {
+22 -10
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
@@ -319,15 +321,20 @@ pub(crate) struct Recoded {
pub note: Option<&'static str>,
}
/// 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>,
}
/// The ICC profile image `bytes` carries ([`source_icc`]), when it is a well-formed profile of
@@ -476,8 +483,8 @@ fn resample_channels(img: DynamicImage, r: &Rule, (w, h): (u32, u32)) -> Dynamic
/// converted by `convert` (colour images). Pixels that keep their colours keep the ICC profile
/// they carry when `profiles` allows it (not in PDF/X-1a, which allows no ICC-based color spaces);
/// 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
/// instead ([`ToSrgb`]), and colour ones then by `convert`, or without it by the conversion
/// `to_srgb` gives ([`ToSrgb::then`]); grey ones that either 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.
pub(crate) fn recode(
bytes: &[u8],
@@ -497,7 +504,8 @@ pub(crate) fn recode(
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()));
let then = to_srgb.and_then(|t| t.then);
let to_srgb = to_srgb.filter(|_| !(grey && (convert.is_some() || then.is_some())));
// 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))) {
@@ -533,6 +541,8 @@ pub(crate) fn recode(
return Recoded { image: None, warning: rule.instead, note: None };
}
let Some(mut img) = pixels.or_else(|| decoded(bytes)) else { return 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),
@@ -550,8 +560,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.
if !changed && as_is && jpeg {
@@ -570,6 +581,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" };
+43 -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
@@ -77,6 +80,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,
@@ -120,6 +126,7 @@ impl Default for ColorOut {
cmyk_profile,
srgb_note: None,
pixels: OnceLock::new(),
tagged_pixels: OnceLock::new(),
cmyk_pixels: OnceLock::new(),
intent,
catalog: None,
@@ -348,13 +355,42 @@ 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)
}
/// 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
+123 -1
View File
@@ -776,7 +776,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 });
for (what, png) in [("RGB", declared(&colour(), &p3)), ("gray", declared(&colour().grayscale(), &gray))] {
let r = crate::images::recode(&png, (100.0, 100.0), &c, false, None, true, srgb_out);
assert!(r.image.is_none() && r.warning.is_some_and(|w| w.contains("not converted to sRGB")), "{what}: {:?}", r.warning);
@@ -980,3 +980,125 @@ 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.
let gray = gray_profile(&[0x01CD]);
let gray_doc = doc(tagged(&colour().grayscale(), &gray, ImageFormat::Tiff), "image/tiff");
for destination in [GENERIC_CMYK, WIDE_GAMUT_RGB] {
let settings = json!({"output": {"conversion": "preserveNumbers", "destination": destination}});
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, {destination}: {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");
}
+7 -1
View File
@@ -5911,7 +5911,13 @@ and then to the destination, instead of having its numbers read as sRGB (a profi
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.
`preserveNumbers` still reads an image's numbers as sRGB. The destination is any profile `edit.colorSettings` lists (default: the document's
`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.
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
@@ -1935,6 +1935,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`).
- SVG import leaves out an SVG shown as an image that it can't read (text that isn't XML, an SVG without a size) and goes on with the images after it, as SVG 2's error processing describes (<https://www.w3.org/TR/SVG2/conform.html>). Only images that decode count toward the 256 nested SVG images an SVG may show, so an image after many broken ones is imported. Every nested SVG image read, decoded or not, counts toward VectorCraft's own limits of 1,024 reads and 512 MB of text per import; past them, nested SVG images are left out with a warning (`crates/svg/tests/it/import_details.rs`).