mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-16 14:17:14 +00:00
Merge pull request #7805 from dotCooCoo/fix/an-image-whose-recode-fails-is-written-without
PDF export: an image whose colors can't be converted is left out with a warning
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -18,6 +18,10 @@ pub(super) const MAX_PATTERN_DEPTH: u32 = 4;
|
||||
/// (`vectorcraft-engine`'s `rasterfx::undecoded_warning`).
|
||||
pub(super) const UNDECODED: &str = "an image couldn't be decoded and is missing from the picture";
|
||||
|
||||
/// The warning for an image left out because its colors can't be converted as the Output
|
||||
/// settings ask, although it could be written in its own colors.
|
||||
pub(super) const UNCONVERTED: &str = "an image couldn't be converted to the Output destination and is missing from the picture";
|
||||
|
||||
/// The warning for an image whose placement cannot be written.
|
||||
pub(super) const UNWRITABLE_IMAGE: &str = "an image couldn't be written and is missing from the picture";
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use super::exporter::{UNDECODED, UNWRITABLE_IMAGE, q, writable, xf};
|
||||
use super::exporter::{UNCONVERTED, UNDECODED, UNWRITABLE_IMAGE, q, writable, xf};
|
||||
use super::{Arc, BlendMode, Color, Exporter, Image, Node, NodeKind, Paint, Rect, Size, Surface, cmyk, krilla};
|
||||
use krilla::color::device_n::{Colorant, DeviceNSpace, Process};
|
||||
use krilla::image::{BitsPerComponent, CustomImage, ImageColorspace};
|
||||
@@ -126,7 +126,9 @@ impl Exporter<'_> {
|
||||
/// settings say ([`crate::images::recode`], [`crate::images::recode_cmyk`] for CMYK images);
|
||||
/// cached by key (and size when images are resampled). With `interpolate` (and the export's
|
||||
/// own setting), viewers may smooth it. `None`, with [`UNDECODED`] among the warnings, for an
|
||||
/// image that is missing, can't be decoded or is in [`Self::left_out`].
|
||||
/// image that is missing, can't be decoded or is in [`Self::left_out`]; `None`, with
|
||||
/// [`UNCONVERTED`], for one whose colors the Output settings convert but that can only be
|
||||
/// written in its own ([`crate::images::Recoded::unconverted`]).
|
||||
fn load_image(&mut self, im: &vectorcraft_doc::ImageObject, size: (f64, f64), interpolate: bool) -> Option<Image> {
|
||||
let key = im.key.as_str();
|
||||
let c = self.compression;
|
||||
@@ -142,6 +144,7 @@ impl Exporter<'_> {
|
||||
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 mut unconverted = false;
|
||||
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 {
|
||||
@@ -153,6 +156,12 @@ impl Exporter<'_> {
|
||||
} else {
|
||||
crate::images::recode(&blob.bytes, size, c, interpolate, out.pixels(), profiles, to_srgb)
|
||||
};
|
||||
if r.unconverted {
|
||||
// The source image would be written in its own colors: it is left out, with a
|
||||
// warning that names the conversion when it could have been written.
|
||||
unconverted = embed(blob, interpolate, self.sixteen_bit, profiles).is_some();
|
||||
return None;
|
||||
}
|
||||
let img = r.image.or_else(|| embed(blob, interpolate, self.sixteen_bit, profiles));
|
||||
// An image left out gets the warning below instead.
|
||||
for w in [r.warning, r.note].into_iter().flatten().filter(|_| img.is_some()) {
|
||||
@@ -160,7 +169,9 @@ impl Exporter<'_> {
|
||||
}
|
||||
img
|
||||
});
|
||||
if img.is_none() {
|
||||
if unconverted {
|
||||
self.warn(UNCONVERTED);
|
||||
} else if img.is_none() {
|
||||
self.warn(UNDECODED);
|
||||
}
|
||||
self.images.insert(cache, img.clone());
|
||||
|
||||
+52
-23
@@ -320,6 +320,9 @@ pub(crate) struct Recoded {
|
||||
/// Set when the image's colors are converted to the destination without its ICC profile,
|
||||
/// which can't be read.
|
||||
pub note: Option<&'static str>,
|
||||
/// Set when the colors were to be converted but the image couldn't be decoded within the
|
||||
/// allowance or written with them: the source image, kept as it is, would be in its own colors.
|
||||
pub unconverted: bool,
|
||||
}
|
||||
|
||||
/// How [`recode`] converts a gray or RGB image that carries an ICC profile to sRGB (Convert to
|
||||
@@ -521,7 +524,10 @@ fn resample_channels(img: DynamicImage, r: &Rule, (w, h): (u32, u32)) -> Dynamic
|
||||
/// 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.
|
||||
/// 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),
|
||||
@@ -531,7 +537,7 @@ pub(crate) fn recode(
|
||||
profiles: SourceProfiles,
|
||||
to_srgb: Option<ToSrgb>,
|
||||
) -> Recoded {
|
||||
let keep = Recoded { image: None, warning: None, note: None };
|
||||
let keep = Recoded { image: None, warning: None, note: None, unconverted: convert.is_some() };
|
||||
let Ok(reader) = ImageReader::new(Cursor::new(bytes)).with_guessed_format() else { return keep };
|
||||
let jpeg = reader.format() == Some(ImageFormat::Jpeg);
|
||||
let Ok(mut decoder) = reader.into_decoder() else { return keep };
|
||||
@@ -549,23 +555,25 @@ pub(crate) fn recode(
|
||||
note = Some(CONVERTED_AS_SRGB);
|
||||
None
|
||||
}
|
||||
Some((None, _)) => return Recoded { image: None, warning: Some(UNCONVERTED), note: None },
|
||||
Some((None, _)) => return Recoded { image: None, warning: Some(UNCONVERTED), note: None, unconverted: false },
|
||||
None => None,
|
||||
};
|
||||
// Pixels that can't be decoded are kept as they are, with a warning when they were to be
|
||||
// converted.
|
||||
let keep = if source.is_some() { Recoded { image: None, warning: Some(UNDECODED), note: None } } else { keep };
|
||||
let keep = if source.is_some() { Recoded { warning: Some(UNDECODED), ..keep } } else { keep };
|
||||
// What the header declares is decoded within the image allowance, not whatever it asks for.
|
||||
// Grey pixels aren't converted.
|
||||
if decoder.set_limits(limits()).is_err() {
|
||||
return keep;
|
||||
return Recoded { unconverted: convert.is_some() && !grey, ..keep };
|
||||
}
|
||||
let (mut kind, pixels) = if grey {
|
||||
// Only the pixels tell monochrome images from greyscale ones: decoded unless both keep it.
|
||||
let (g, m) = (rule(c, Kind::Gray), rule(c, Kind::Mono));
|
||||
if source.is_none() && kept(&g, dims, size, jpeg) && kept(&m, dims, size, jpeg) && g.instead == m.instead {
|
||||
return Recoded { image: None, warning: g.instead, note: None };
|
||||
return Recoded { image: None, warning: g.instead, note: None, unconverted: false };
|
||||
}
|
||||
let Ok(img) = DynamicImage::from_decoder(decoder) else { return keep };
|
||||
// Grey pixels aren't converted.
|
||||
let Ok(img) = DynamicImage::from_decoder(decoder) else { return Recoded { unconverted: false, ..keep } };
|
||||
(if bilevel(&img) { Kind::Mono } else { Kind::Gray }, Some(img))
|
||||
} else {
|
||||
(Kind::Color, None)
|
||||
@@ -573,9 +581,14 @@ pub(crate) fn recode(
|
||||
let mut rule = rule(c, kind);
|
||||
let convert = convert.filter(|_| kind == Kind::Color);
|
||||
if kept(&rule, dims, size, jpeg) && convert.is_none() && source.is_none() {
|
||||
return Recoded { image: None, warning: rule.instead, note: None };
|
||||
return Recoded { image: None, warning: rule.instead, note: None, unconverted: false };
|
||||
}
|
||||
let Some(mut img) = pixels.or_else(|| decoded(bytes)) else { return keep };
|
||||
// Pixels that can't be read can't be written in their own colors either; ones beyond the
|
||||
// allowance can.
|
||||
let mut img = match pixels.map_or_else(|| decoded_within(bytes), Ok) {
|
||||
Ok(img) => img,
|
||||
Err(limited) => return Recoded { unconverted: limited && convert.is_some(), ..keep },
|
||||
};
|
||||
if let Some((p, t)) = &source {
|
||||
let srgb = match into_srgb(img, p, t.intent) {
|
||||
Some(s) => Some(s),
|
||||
@@ -585,7 +598,7 @@ pub(crate) fn recode(
|
||||
note = Some(CONVERTED_AS_SRGB);
|
||||
None
|
||||
}
|
||||
None => return Recoded { image: None, warning: Some(UNCONVERTED), note: None },
|
||||
None => return Recoded { image: None, warning: Some(UNCONVERTED), note: None, unconverted: false },
|
||||
};
|
||||
img = match srgb {
|
||||
Some((srgb, changed)) => {
|
||||
@@ -604,18 +617,19 @@ pub(crate) fn recode(
|
||||
&& let Some(data) = jpeg_data(bytes, profiles == SourceProfiles::Remove)
|
||||
{
|
||||
let image = Image::from_jpeg_with_icc(data.into(), None, interpolate).ok();
|
||||
return Recoded { image, warning: rule.instead, note: None };
|
||||
return Recoded { image, warning: rule.instead, note: None, unconverted: false };
|
||||
}
|
||||
// Not resampled and lossless: written at its own depth.
|
||||
if as_is && jpeg_quality(&rule, jpeg).is_none() {
|
||||
return Recoded { image: from_decoded(srgb, None, interpolate, t.sixteen_bit), warning: rule.instead, note: None };
|
||||
let image = from_decoded(srgb, None, interpolate, t.sixteen_bit);
|
||||
return Recoded { image, warning: rule.instead, note: None, unconverted: false };
|
||||
}
|
||||
srgb
|
||||
}
|
||||
None => {
|
||||
let Some(img) = decoded(bytes) else { return keep };
|
||||
img
|
||||
}
|
||||
None => match decoded_within(bytes) {
|
||||
Ok(img) => img,
|
||||
Err(limited) => return Recoded { unconverted: limited && convert.is_some(), ..keep },
|
||||
},
|
||||
};
|
||||
}
|
||||
// Pixels that keep their colours keep the profile they are in; converted ones are in the
|
||||
@@ -650,7 +664,8 @@ pub(crate) fn recode(
|
||||
to_jpeg(&samples, space, width, height, q, interpolate, icc.as_deref().map(Vec::as_slice))
|
||||
});
|
||||
let image = jpeg.or_else(|| from_rgba(rgba.as_raw(), width, height, interpolate, convert, icc));
|
||||
Recoded { image, warning: rule.instead, note }
|
||||
let unconverted = image.is_none() && convert.is_some();
|
||||
Recoded { image, warning: rule.instead, note, unconverted }
|
||||
}
|
||||
|
||||
/// A colorized image's coverage (one sample a pixel, `w` × `h`, see
|
||||
@@ -681,6 +696,7 @@ pub(crate) fn coverage_sized(w: u32, h: u32, cover: Vec<u8>, size: (f64, f64), c
|
||||
/// [`mask_alpha`]) the image is lossless and carries it as its soft mask; `None` then when its
|
||||
/// inks can't be read. When its numbers are kept, the image is tagged as `tag` says, and is
|
||||
/// untagged without a profile; converted pixels are never tagged with it.
|
||||
/// With `convert`, an image whose inks can't be read or written is [`Recoded::unconverted`].
|
||||
pub(crate) fn recode_cmyk(
|
||||
blob: &ImageBlob,
|
||||
size: (f64, f64),
|
||||
@@ -704,16 +720,22 @@ pub(crate) fn recode_cmyk(
|
||||
let image = (u64::from(w) * u64::from(h) <= MAX_EMBED_PIXELS)
|
||||
.then(|| Image::from_jpeg_with_icc(data.into(), icc.map(|i| i.to_vec().into()), interpolate).ok())
|
||||
.flatten();
|
||||
return Recoded { image, warning: rule.instead, note: None };
|
||||
return Recoded { image, warning: rule.instead, note: None, unconverted: false };
|
||||
}
|
||||
}
|
||||
// Inks that can't be read can't be converted: the image is not to be kept as it is.
|
||||
let unconverted = Recoded { image: None, warning: None, note: None, unconverted: true };
|
||||
let Some(inks) = blob.cmyk() else {
|
||||
return Recoded { image: None, warning: Some(if jpeg { CMYK_KEPT } else { CMYK_RGB }), note: None };
|
||||
if convert.is_some() {
|
||||
return unconverted;
|
||||
}
|
||||
return Recoded { image: None, warning: Some(if jpeg { CMYK_KEPT } else { CMYK_RGB }), note: None, unconverted: false };
|
||||
};
|
||||
let (width, height) = sized(&rule, (inks.width, inks.height), size);
|
||||
let (inks, alpha) = match resampled_inks(inks, alpha, &rule, (width, height)) {
|
||||
Ok(r) => r,
|
||||
Err(warning) => return Recoded { image: None, warning, note: None },
|
||||
Err(_) if convert.is_some() => return unconverted,
|
||||
Err(warning) => return Recoded { image: None, warning, note: None, unconverted: false },
|
||||
};
|
||||
let (samples, space) = match convert {
|
||||
Some(p) => p.convert(&inks),
|
||||
@@ -722,7 +744,8 @@ pub(crate) fn recode_cmyk(
|
||||
// JPEG needs opaque pixels.
|
||||
let image = jpeg_quality(&rule, jpeg).filter(|_| alpha.is_none()).and_then(|q| to_jpeg(&samples, space, width, height, q, interpolate, icc));
|
||||
let image = image.or_else(|| lossless(samples, alpha, space, width, height, interpolate, icc));
|
||||
Recoded { image, warning: rule.instead, note: None }
|
||||
let unconverted = image.is_none() && convert.is_some();
|
||||
Recoded { image, warning: rule.instead, note: None, unconverted }
|
||||
}
|
||||
|
||||
/// Ink amounts (four bytes a pixel) and their alpha (one byte a pixel), if any.
|
||||
@@ -767,9 +790,15 @@ fn limits() -> image::Limits {
|
||||
|
||||
/// `bytes` decoded within [`limits`]: an image whose header asks for more is not decoded.
|
||||
fn decoded(bytes: &[u8]) -> Option<DynamicImage> {
|
||||
let mut r = ImageReader::new(Cursor::new(bytes)).with_guessed_format().ok()?;
|
||||
decoded_within(bytes).ok()
|
||||
}
|
||||
|
||||
/// `bytes` decoded like [`decoded`]; on failure, whether the decoder stopped at [`limits`]
|
||||
/// (`true`) rather than at data it can't read (`false`).
|
||||
fn decoded_within(bytes: &[u8]) -> Result<DynamicImage, bool> {
|
||||
let mut r = ImageReader::new(Cursor::new(bytes)).with_guessed_format().map_err(|_| false)?;
|
||||
r.limits(limits());
|
||||
r.decode().ok()
|
||||
r.decode().map_err(|e| matches!(e, image::ImageError::Limits(_)))
|
||||
}
|
||||
|
||||
/// The alpha an opacity mask whose art is greyscale image `blob` alone gives the image of
|
||||
|
||||
@@ -622,6 +622,38 @@ fn a_kept_cmyk_jpeg_declaring_too_many_pixels_is_left_out() {
|
||||
}
|
||||
}
|
||||
|
||||
/// A CMYK JPEG whose inks can't be read (it declares more pixels than CMYK images are decoded
|
||||
/// with, though fewer than the writer embeds) is written with its own numbers only when they are
|
||||
/// kept: when the Output settings convert its colors it is left out with a warning, in every
|
||||
/// standard.
|
||||
#[test]
|
||||
fn a_cmyk_jpeg_whose_inks_cant_be_read_is_left_out_when_its_colors_are_converted() {
|
||||
let mut jpg = cmyk_jpeg(&flat([0, 102, 255, 0], 4), 2, 2);
|
||||
// Height and width of the SOF0 segment (after its marker, length and precision): 8200 × 8200.
|
||||
let sof = jpg.windows(2).position(|w| w == [0xFF, 0xC0]).unwrap();
|
||||
jpg[sof + 5..sof + 9].copy_from_slice(&[0x20, 0x08, 0x20, 0x08]);
|
||||
let blob = ImageBlob::new("image/jpeg", jpg);
|
||||
assert!(blob.is_cmyk() && blob.cmyk().is_none());
|
||||
let d = image_doc(blob, 2, 2);
|
||||
let out = export_with_report(&d, &opts(json!({}))).unwrap();
|
||||
let kept = written(&out.bytes);
|
||||
assert!(kept.len() == 1 && kept[0].space == "DeviceCMYK", "kept as it is: {kept:?}");
|
||||
let unconverted = "an image couldn't be converted to the Output destination and is missing from the picture";
|
||||
for s in [
|
||||
json!({"output": {"conversion": "destination", "destination": DEVICE_CMYK}}),
|
||||
json!({"output": {"conversion": "destination", "destination": SRGB}}),
|
||||
json!({"standard": "pdfX1a", "output": {"conversion": "destination", "destination": DEVICE_CMYK}}),
|
||||
json!({"standard": "pdfX4", "output": {"conversion": "destination", "destination": DEVICE_CMYK}}),
|
||||
json!({"standard": "pdfA2b", "output": {"conversion": "destination", "destination": DEVICE_CMYK}}),
|
||||
] {
|
||||
let out = export_with_report(&d, &opts(s.clone())).unwrap_or_else(|e| panic!("{s}: {e}"));
|
||||
assert!(written(&out.bytes).is_empty(), "{s}");
|
||||
assert!(out.warnings.iter().any(|w| w == unconverted), "{s}: {:?}", out.warnings);
|
||||
let other = out.warnings.iter().any(|w| w.contains("couldn't be decoded") || w.contains("written as it is"));
|
||||
assert!(!other, "{s}: {:?}", out.warnings);
|
||||
}
|
||||
}
|
||||
|
||||
/// The profile each transparency group of written PDF `bytes` blends in: its ICC-based space's
|
||||
/// profile, or `None` for DeviceCMYK.
|
||||
fn group_profiles(bytes: &[u8]) -> Vec<Option<Vec<u8>>> {
|
||||
|
||||
@@ -270,6 +270,54 @@ fn images_declaring_more_than_the_allowance_are_not_decoded() {
|
||||
assert!(r.image.is_none(), "kept as it is");
|
||||
}
|
||||
|
||||
/// When the Output settings convert colors, a color image beyond the decode allowance can't be
|
||||
/// kept as it is: it is unconverted, and so is one whose header can't be read. A color image
|
||||
/// whose pixel data can't be read (tagged with an ICC profile it is converted from or not) can't
|
||||
/// be written in its own colors either, and is kept as it is, as is a grey one, whose pixels
|
||||
/// aren't converted, and any image without a conversion.
|
||||
#[test]
|
||||
fn a_color_image_beyond_the_allowance_for_a_conversion_is_unconverted() {
|
||||
use vectorcraft_color::cms::{DISPLAY_P3, GENERIC_CMYK, icc_bytes};
|
||||
let d = doc(encoded(colour(), ImageFormat::Png), "image/png");
|
||||
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 });
|
||||
assert!(to_srgb.is_some());
|
||||
let c: CompressionSettings = serde_json::from_value(json!({})).unwrap();
|
||||
let half = |mut bytes: Vec<u8>| {
|
||||
bytes.truncate(bytes.len() / 2);
|
||||
bytes
|
||||
};
|
||||
let cut = |img: DynamicImage| half(encoded(img, ImageFormat::Png));
|
||||
let mut p3 = icc_bytes(DISPLAY_P3).unwrap().to_vec();
|
||||
p3[8..12].copy_from_slice(&[4, 0x20, 0, 0]);
|
||||
// `declared_png`'s header declaring RGB pixels (color type 2), with the IHDR chunk's CRC
|
||||
// written again.
|
||||
let mut rgb_declared = declared_png(60_000, 60_000);
|
||||
rgb_declared[25] = 2;
|
||||
let mut crc = flate2::Crc::new();
|
||||
crc.update(&rgb_declared[12..29]);
|
||||
rgb_declared[29..33].copy_from_slice(&crc.sum().to_be_bytes());
|
||||
let cases = [
|
||||
("RGB declaring more than the allowance", rgb_declared, true),
|
||||
("RGB", cut(colour()), false),
|
||||
("tagged RGB", half(tagged(&colour(), &p3, ImageFormat::Png)), false),
|
||||
("unreadable", vec![1, 2, 3], true),
|
||||
("grey", cut(colour().grayscale()), false),
|
||||
("grey declaring more than the allowance", declared_png(60_000, 60_000), false),
|
||||
];
|
||||
for (what, bytes, unconverted) in cases {
|
||||
let r = crate::images::recode(&bytes, (72.0, 72.0), &c, false, out.pixels(), crate::images::SourceProfiles::Keep, to_srgb);
|
||||
assert!(r.image.is_none(), "{what}");
|
||||
assert_eq!(r.unconverted, unconverted, "{what}");
|
||||
assert!(
|
||||
!crate::images::recode(&bytes, (72.0, 72.0), &c, false, None, crate::images::SourceProfiles::Keep, None).unconverted,
|
||||
"{what}, no conversion"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// A version 2.1 display ICC profile for colour space `space` (`RGB ` or `GRAY`), `len` bytes in
|
||||
/// all, with an empty tag table, every byte after the tag count different from its neighbors.
|
||||
fn icc_profile(space: &[u8; 4], len: usize) -> Vec<u8> {
|
||||
|
||||
+5
-1
@@ -5928,7 +5928,11 @@ 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.
|
||||
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
|
||||
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
|
||||
|
||||
@@ -1944,6 +1944,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur
|
||||
- The pixels of a PNG, JPEG, GIF or WebP file that Place decodes to check them are kept in the image store the renderers share, so the canvas's first frame with the placed image draws them without decoding the file again on the UI thread: File › Place, a file dropped on the canvas, a click or drag of the place cursor, `file.place`, and Paste of such an image. A CMYK JPEG is still decoded when it is first drawn (`crates/ui-egui/src/placing.rs`, `crates/render/src/tests.rs`).
|
||||
- A photo whose EXIF orientation turns or flips it (a camera held upright or upside down) is placed and opened upright, as it was taken; the image is stored as it is seen (#4284). A quarter turn swaps the resolution's axes, so the image keeps its physical size. TIFFs read without the image decoder (grayscale with extra channels, CCITT Group 3, CMYK with one plane per ink) follow their Orientation tag too, and a turned CMYK JPEG or TIFF keeps its inks, at the 8 or 16 bits the file has, as a CMYK TIFF.
|
||||
- PDF export writes a CMYK image that keeps its numbers in an `ICCBased` color space holding, byte for byte, the CMYK profile the image carries (a CMYK TIFF's tag 34675, or a CMYK JPEG's `ICC_PROFILE` APP2 segments) when `output.profiles` is `all` or `taggedSource`, and in PDF/A-2b, PDF/X-3 and PDF/X-4 unless it is `destination` ([the help page](https://helpx.adobe.com/illustrator/desktop/save-and-export/export-files-to-different-formats/pdf-marks-bleeds-and-color-output-options.html)). This covers a CMYK JPEG embedded as it is, one the Compression settings resample or compress again, a TIFF written again, and an image written with its mask as its soft mask. With `none`, and in PDF/X-1a, the image is DeviceCMYK and a JPEG's own profile is left out, so PDF/X-1a export writes a CMYK JPEG that carries a profile. Pixels the Output settings convert are never tagged with the profile of their old numbers. A profile tags an image only when its size, signature, class, CMYK color space and tag table are well formed and it is at most 16 MiB (VectorCraft's own limit). Transparency in a tagged CMYK document blends in the document's CMYK profile; when the file holds no space of that profile it blends in DeviceCMYK, or keeps its RGB space in PDF/A, and never in an image's own profile (`crates/pdf/src/tests/cmykimages.rs`, `export::writer::tests`).
|
||||
- When the Output settings convert an image's colors ([the help page](https://helpx.adobe.com/illustrator/desktop/save-and-export/export-files-to-different-formats/pdf-marks-bleeds-and-color-output-options.html)), PDF export leaves out an image whose pixels can't be decoded or written in the destination's colors, with the warning "an image couldn't be converted to the Output destination and is missing from the picture", in every standard, instead of writing it in its own colors. This covers a CMYK image with more than 2^26 pixels, the most VectorCraft reads CMYK inks for, and a color image that could be embedded as it is but is more than VectorCraft decodes. A color image 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. Gray images, whose pixels are not converted, images in a file that converts no colors, and a gray or RGB image that an sRGB destination would convert from its ICC profile (it keeps the profile, with a warning) are written as before, and an image that can't be written at all still gets the warning that it couldn't be decoded (`crates/pdf/src/tests/cmykimages.rs`, `crates/pdf/src/tests/compression.rs`).
|
||||
- PDF export with `output.profiles` set to `none` (Don't Include Profiles) writes no image with the ICC profile it carries, as [the help page](https://helpx.adobe.com/illustrator/desktop/save-and-export/export-files-to-different-formats/pdf-marks-bleeds-and-color-output-options.html) describes for that setting: gray and RGB PNG, JPEG and TIFF images embedded as they are, resampled or compressed again, and CMYK JPEG images. A JPEG kept as it is loses its `ICC_PROFILE` APP2 segments, its other segments and compressed samples unchanged. PDF/A-2b, PDF/X-3 and PDF/X-4 files keep the profiles they tag images with. Left unset (the default, `"default"`, listed as Default in Save PDF), the setting writes device colors while gray and RGB images keep their profiles, as before; that default is VectorCraft's own rule (`a_set_dont_include_profiles_removes_image_profiles`, `a_set_dont_include_profiles_takes_a_cmyk_jpegs_profile_out`).
|
||||
- PDF import keeps the CMYK profile of an image in a four-component `ICCBased` color space, whose stream holds the profile ([ISO 32000-1, §8.6.5.5](https://opensource.adobe.com/dc-acrobat-sdk-docs/pdfstandards/PDF32000_2008.pdf#page=157)), byte for byte with the image's ink amounts, so PDF export can write the image in it again. A CMYK TIFF carries it as tag 34675, whatever the image's Decode array and bit depth ([ICC.1:2010, Annex B](https://www.color.org/specification/ICC1v43_2010-12.pdf)). A CMYK JPEG kept as it is carries it in `ICC_PROFILE` APP2 segments in place of a profile of its own, with its compressed samples unchanged, and one whose segments can't hold it is stored as a CMYK TIFF carrying it. A profile that isn't well formed, isn't of CMYK colors or is over 16 MiB (VectorCraft's own limit) leaves the image's inks as they are, untagged. DeviceCMYK and DeviceN images carry no profile, and a CMYK TIFF's tag 34675 is read up to 16 MiB. EPS and PostScript import does not keep one: PostScript defines no `ICCBased` profile stream (`crates/pdf/src/tests/cmykimages.rs`, `cmyk::tests`).
|
||||
- An image that Open and Place store again keeps the ICC profile its file embeds and its 16-bit samples. A turned PNG, JPEG, WebP or TIFF stored as PNG, and a TIFF the image decoder reads, keep their gray or RGB samples at 8 or 16 bits with their gray or RGB profile in the PNG's `iCCP` chunk ([PNG specification, iCCP](https://www.w3.org/TR/png-3/#11iCCP)). A CMYK TIFF stored with one plane per ink and a turned CMYK JPEG or TIFF keep their CMYK profile as TIFF tag 34675, a JPEG's put together from all its APP2 segments ([ICC image-format guide](https://github.com/InternationalColorConsortium/iccDEV/blob/master/iccdev-mcp/docs/icc-format-guide.md)). A profile whose color space differs from the stored samples' is left out. The profile is kept in the stored image; how CMYK inks are drawn and exported to PDF does not change (`crates/engine/src/cmd/fileio/tests.rs`).
|
||||
|
||||
Reference in New Issue
Block a user