mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-18 07:49:26 +00:00
Links: Unembed writes several selected embedded images to one chosen folder
The Links panel menu's Unembed… now works with several embedded images
selected: it asks for one folder, writes a file for each image there in
the format the image is stored in, and links each image to its file,
keeping its bounds, in one undo step. On the web each image is
downloaded instead.
links.unembed takes `ids` and `folder` for this form. Each file is named
after its image, with characters a file name can't hold replaced by `_`;
a taken name is numbered (`Name 2`), and a file already in the folder is
never replaced. Linked images among `ids` are skipped and listed. When an
image can't be written, the files the call wrote are removed and the
document does not change. A folder outside the automation write roots is
refused. The one-image `{id, path}` form is unchanged.
This commit is contained in:
@@ -36,7 +36,7 @@ use vectorcraft_doc::{
|
||||
use vectorcraft_geom::{Affine, FillRule, PathData, Rect, shapes};
|
||||
|
||||
use super::fileio::{self, RasterImage, absolute_path, file_created, file_stamp, read_file, write_file};
|
||||
use super::{CommandSpec, EngineError, Result, Session, bad, bool_or, cmd, has_doc, ids_param, object_param, str_param, switch_or};
|
||||
use super::{CommandSpec, EngineError, Result, Session, bad, bool_or, cmd, has_doc, ids_param, object_param, str_param, switch_or, text_param};
|
||||
|
||||
pub fn specs() -> Vec<CommandSpec> {
|
||||
vec![
|
||||
@@ -108,7 +108,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
"Unembed",
|
||||
[],
|
||||
None,
|
||||
"{id?: an embedded image (default: the one selected), path?} write the image's pixels to the file at path (PNG, JPEG, GIF or WebP as stored, other images as PNG; a path ending in .png/.jpg/.jpeg/.gif/.webp/.tif/.tiff/.bmp converts them) and link the image to it, keeping its bounds. One undo step → {id, path}; no path → {name, dataBase64} (nothing changes: there is no file to link to)",
|
||||
"{id?: an embedded image (default: the one selected), path?, ids?: [image ids] (with folder; default: the selected embedded images), folder?} write the image's pixels to the file at path (PNG, JPEG, GIF or WebP as stored, other images as PNG; a path ending in .png/.jpg/.jpeg/.gif/.webp/.tif/.tiff/.bmp converts them) and link the image to it, keeping its bounds. One undo step → {id, path}; no path → {name, dataBase64} (nothing changes: there is no file to link to). Several images, with ids and folder: write each embedded image to a new file in folder, as stored (as PNG when that format is not one of VectorCraft's raster file formats), named after the image (characters a file name can't hold become _; Image when nothing is left), with Name 2 … Name 99 when the name is taken; a file already there is never replaced. Linked images among ids are left as they are. Each image links to its file and keeps its bounds. One undo step (undo does not remove the files); when a file can't be written, the files this call wrote are removed and nothing changes → {unembedded: [{id, path}], skipped: [ids of linked images]}; id or path with ids or folder is an error",
|
||||
has_doc,
|
||||
unembed
|
||||
),
|
||||
@@ -2669,8 +2669,28 @@ fn convert_image(bytes: &[u8], ext: &str) -> std::result::Result<Vec<u8>, String
|
||||
craft_image_codecs::encode(&raw, format, &craft_image_codecs::EncodeOptions::default()).map_err(|e| e.to_string())
|
||||
}
|
||||
|
||||
/// The extension of the format embedded image `blob` is stored in (PNG for one Unembed doesn't
|
||||
/// name).
|
||||
fn stored_extension(blob: &vectorcraft_doc::ImageBlob) -> &'static str {
|
||||
fileio::FORMATS.iter().find(|f| f.raster && f.mime == blob.mime).map_or("png", |f| f.extensions.first().copied().unwrap_or("png"))
|
||||
}
|
||||
|
||||
/// The bytes of embedded image `blob` in the format of extension `ext`: its own bytes when it is
|
||||
/// stored in that format, else converted.
|
||||
fn unembed_bytes(blob: &vectorcraft_doc::ImageBlob, ext: &str) -> std::result::Result<Vec<u8>, String> {
|
||||
let same = fileio::format(ext).is_some_and(|f| f.mime == blob.mime);
|
||||
if same { Ok(blob.bytes.to_vec()) } else { convert_image(&blob.bytes, ext) }
|
||||
}
|
||||
|
||||
fn unembed(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
const C: &str = "links.unembed";
|
||||
let given = |k: &str| p.get(k).is_some_and(|v| !v.is_null());
|
||||
if given("ids") || given("folder") {
|
||||
if given("id") || given("path") {
|
||||
return Err(bad(C, "give id and path for one image, or ids and folder for several"));
|
||||
}
|
||||
return unembed_to_folder(s, p);
|
||||
}
|
||||
let st = s.doc()?;
|
||||
let doc = with_brush_art(&st.doc);
|
||||
let id = image_param(st, &doc, p, C)?;
|
||||
@@ -2681,15 +2701,14 @@ fn unembed(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
}
|
||||
let blob = st.doc.images.get(&im.key).filter(|b| !b.is_proxy()).ok_or_else(|| bad(C, "the image's pixels aren't in the document"))?;
|
||||
// As stored (PNG, JPEG, GIF, WebP), unless the path names another format.
|
||||
let stored = fileio::FORMATS.iter().find(|f| f.raster && f.mime == blob.mime).map_or("png", |f| f.extensions.first().copied().unwrap_or("png"));
|
||||
let stored = stored_extension(blob);
|
||||
let path = str_param(p, "path");
|
||||
let ext = match path.map(fileio::extension) {
|
||||
Some(e) if UNEMBED_EXTS.contains(&e.as_str()) => e,
|
||||
Some(e) if !e.is_empty() => return Err(bad(C, format!("can't write .{e} images: use .png, .jpg, .gif, .webp, .tif or .bmp"))),
|
||||
_ => stored.to_string(),
|
||||
};
|
||||
let same = fileio::format(&ext).is_some_and(|f| f.mime == blob.mime);
|
||||
let bytes = if same { blob.bytes.to_vec() } else { convert_image(&blob.bytes, &ext).map_err(|e| bad(C, e))? };
|
||||
let bytes = unembed_bytes(blob, &ext).map_err(|e| bad(C, e))?;
|
||||
let Some(path) = path else {
|
||||
let name = n.display_name();
|
||||
let stem = Path::new(&name).file_stem().map_or_else(|| name.clone(), |s| s.to_string_lossy().into_owned());
|
||||
@@ -2705,6 +2724,142 @@ fn unembed(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
Ok(json!({ "id": id.0, "path": path }))
|
||||
}
|
||||
|
||||
/// `links.unembed {ids?, folder}`: each embedded image of `ids` (default: the selected embedded
|
||||
/// images) written to a new file in `folder` as stored (as PNG when that format is not one of
|
||||
/// VectorCraft's raster file formats) and linked to it, in one undo step. Linked images are skipped. When any image fails, the files written before it
|
||||
/// are removed and the document does not change.
|
||||
fn unembed_to_folder(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
const C: &str = "links.unembed";
|
||||
let folder = text_param(p, "folder", C)?.filter(|f| !f.is_empty()).ok_or_else(|| bad(C, "missing `folder`"))?;
|
||||
let st = s.doc()?;
|
||||
let doc = with_brush_art(&st.doc);
|
||||
let ids = ids_param(p, "ids", C)?.unwrap_or_else(|| selected_images(st, |im| im.link.is_none()));
|
||||
let mut seen = BTreeSet::new();
|
||||
if !ids.iter().all(|id| seen.insert(id.0)) {
|
||||
return Err(bad(C, "`ids` names an object twice"));
|
||||
}
|
||||
let (mut embedded, mut skipped) = (vec![], vec![]);
|
||||
for &id in &ids {
|
||||
let n = stored(&doc, id).ok_or(crate::EngineError::NoNode(id))?;
|
||||
let im = image_of(&doc, id).ok_or_else(|| bad(C, format!("object {} is not an image", id.0)))?;
|
||||
if im.link.is_some() {
|
||||
skipped.push(id);
|
||||
continue;
|
||||
}
|
||||
let blob = st.doc.images.get(&im.key).filter(|b| !b.is_proxy()).ok_or_else(|| bad(C, "the image's pixels aren't in the document"))?;
|
||||
embedded.push((id, n.display_name(), blob));
|
||||
}
|
||||
match (embedded.is_empty(), skipped.first()) {
|
||||
(true, Some(id)) => return Err(bad(C, format!("image {} is linked already", id.0))),
|
||||
(true, None) => return Err(bad(C, "select an image")),
|
||||
_ => {}
|
||||
}
|
||||
let dir = absolute_path(folder);
|
||||
writable_folder(&dir)?;
|
||||
// One image at a time: its bytes are read before its file is written, so pixels that can't be
|
||||
// read leave no file behind.
|
||||
let mut written: Vec<String> = vec![];
|
||||
let mut reads = Vec::with_capacity(embedded.len());
|
||||
let wrote = embedded.iter().try_for_each(|(id, name, blob)| {
|
||||
vectorcraft_doc::cancel::check()?;
|
||||
let ext = stored_extension(blob);
|
||||
let bytes = unembed_bytes(blob, ext).map_err(|e| bad(C, e))?;
|
||||
let name = format!("{}.{ext}", unembed_stem(name));
|
||||
let img = linked_image(&bytes, Some(Path::new(&dir).join(&name).to_string_lossy().as_ref()))?;
|
||||
let path = write_numbered(&dir, &name, &bytes)?;
|
||||
written.push(path.clone());
|
||||
reads.push((*id, (link_info(&path, &bytes), img)));
|
||||
Ok(())
|
||||
});
|
||||
let remove_written = |written: &[String]| {
|
||||
for path in written {
|
||||
let _ = std::fs::remove_file(path);
|
||||
}
|
||||
};
|
||||
if let Err(e) = wrote {
|
||||
remove_written(&written);
|
||||
return Err(e);
|
||||
}
|
||||
drop(doc);
|
||||
let done: Vec<Value> = reads.iter().map(|(id, (l, _))| json!({ "id": id.0, "path": l.path })).collect();
|
||||
let edited = s.edit("Unembed", |d, _| {
|
||||
editing_brush_art(d, |d| reads.into_iter().try_for_each(|(id, read)| install(d, &[id], read, Some(Preserve::Bounds), None)))
|
||||
});
|
||||
if let Err(e) = edited {
|
||||
remove_written(&written);
|
||||
return Err(e);
|
||||
}
|
||||
Ok(json!({ "unembedded": done, "skipped": ids_json(&skipped) }))
|
||||
}
|
||||
|
||||
/// The name Unembed gives image `name`'s file in a folder, before its extension: the name without
|
||||
/// a folder part or extension, each character a file name can't hold on some system
|
||||
/// (`/ \ : * ? " < > |` and control characters) as `_`, without leading spaces or trailing dots and
|
||||
/// spaces, at most 150 bytes long, and `Image` when nothing is left. A name Windows keeps for a
|
||||
/// device (`CON`, `NUL`, `COM1` …) gets `_` after it.
|
||||
fn unembed_stem(name: &str) -> String {
|
||||
let base = name.rsplit(['/', '\\']).next().unwrap_or_default();
|
||||
let stem = match base.rfind('.') {
|
||||
Some(i) if i > 0 => &base[..i],
|
||||
_ => base,
|
||||
};
|
||||
let mut clean = String::new();
|
||||
for c in stem.chars().map(|c| if c.is_control() || "/\\:*?\"<>|".contains(c) { '_' } else { c }) {
|
||||
if clean.len() + c.len_utf8() > 150 {
|
||||
break;
|
||||
}
|
||||
clean.push(c);
|
||||
}
|
||||
let clean = clean.trim_start_matches(' ').trim_end_matches(['.', ' ']);
|
||||
if clean.is_empty() {
|
||||
return "Image".to_string();
|
||||
}
|
||||
let device = clean.split('.').next().unwrap_or_default().trim_end().to_ascii_uppercase();
|
||||
let numbered = |prefix: &str| device.strip_prefix(prefix).is_some_and(|d| d.len() == 1 && matches!(d.as_bytes().first(), Some(b'1'..=b'9')));
|
||||
if matches!(device.as_str(), "CON" | "PRN" | "AUX" | "NUL") || numbered("COM") || numbered("LPT") {
|
||||
format!("{clean}_")
|
||||
} else {
|
||||
clean.to_string()
|
||||
}
|
||||
}
|
||||
|
||||
/// Folder `path` may take Unembed's files: inside the automation write roots, and a folder.
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
fn writable_folder(path: &str) -> Result<()> {
|
||||
crate::file_access::check_write(path).map_err(EngineError::Other)?;
|
||||
if !std::fs::metadata(path).is_ok_and(|m| m.is_dir()) {
|
||||
return Err(EngineError::Other(format!("{path} is not a folder")));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Write `bytes` to a new file named `name` in folder `dir`, never replacing a file there: `Name.ext`,
|
||||
/// else `Name 2.ext` up to `Name 99.ext`, as [`fileio::copy_new`] names them → its path.
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
fn write_numbered(dir: &str, name: &str, bytes: &[u8]) -> Result<String> {
|
||||
use std::io::Write as _;
|
||||
let create = |to: &Path| {
|
||||
crate::file_access::check_write(&to.to_string_lossy()).map_err(|e| std::io::Error::new(std::io::ErrorKind::PermissionDenied, e))?;
|
||||
vectorcraft_format::write_new_with(to, |f| f.write_all(bytes))
|
||||
};
|
||||
match fileio::copy_new(Path::new(name), Path::new(dir), create, |_, _| false) {
|
||||
Ok(Some(fileio::Placed::Copied(to) | fileio::Placed::Kept(to))) => Ok(to.to_string_lossy().into_owned()),
|
||||
Ok(None) => Err(EngineError::Other(format!("every numbered name for {name} is taken in that folder"))),
|
||||
Err(e) => Err(EngineError::Other(format!("{dir}: {e}"))),
|
||||
}
|
||||
}
|
||||
|
||||
/// The web has no folders to write to.
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
fn writable_folder(_: &str) -> Result<()> {
|
||||
Err(EngineError::Other("no file system here".into()))
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
fn write_numbered(_: &str, _: &str, _: &[u8]) -> Result<String> {
|
||||
Err(EngineError::Other("no file system here".into()))
|
||||
}
|
||||
|
||||
/// Placement Options as `{preserve, align, clip}`.
|
||||
fn placement_json(o: PlacementOptions) -> Value {
|
||||
json!({ "preserve": o.preserve.id(), "align": o.align.id(), "clip": o.clip })
|
||||
@@ -2884,4 +3039,28 @@ mod tests {
|
||||
let c = read();
|
||||
assert!(!Arc::ptr_eq(&a.blob.bytes, &c.blob.bytes));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unembed_names_a_file_after_the_image_with_only_characters_a_file_name_holds() {
|
||||
for (name, stem) in [
|
||||
("photo.png", "photo"),
|
||||
("Image", "Image"),
|
||||
("../../etc/passwd", "passwd"),
|
||||
("C:\\art\\logo.tif", "logo"),
|
||||
("a:b*c?d\"e<f>g|h", "a_b_c_d_e_f_g_h"),
|
||||
("tab\there", "tab_here"),
|
||||
(" name. .png", "name"),
|
||||
("..", "Image"),
|
||||
("", "Image"),
|
||||
(".hidden", ".hidden"),
|
||||
("CON.png", "CON_"),
|
||||
("lpt1", "lpt1_"),
|
||||
("COM0", "COM0"),
|
||||
("console", "console"),
|
||||
] {
|
||||
assert_eq!(unembed_stem(name), stem, "{name:?}");
|
||||
}
|
||||
let long = unembed_stem(&"é".repeat(200));
|
||||
assert!(long.len() <= 150 && long.chars().all(|c| c == 'é'), "{}", long.len());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -203,6 +203,128 @@ fn unembed_of_pixels_that_cant_be_read_writes_no_file() {
|
||||
assert!(image(&s, id).link.is_none());
|
||||
}
|
||||
|
||||
/// The files of folder `dir`, sorted by name.
|
||||
fn files_in(dir: &str) -> Vec<String> {
|
||||
let mut names: Vec<String> = std::fs::read_dir(dir).unwrap().map(|e| e.unwrap().file_name().to_string_lossy().into_owned()).collect();
|
||||
names.sort();
|
||||
names
|
||||
}
|
||||
|
||||
/// The path of the file `name` in folder `dir`.
|
||||
fn file_in(dir: &str, name: &str) -> String {
|
||||
std::path::Path::new(dir).join(name).to_string_lossy().into_owned()
|
||||
}
|
||||
|
||||
/// Several images unembed into one folder: each gets a new file named after it (a taken name
|
||||
/// numbered, a file already there never replaced), links to it and keeps its bounds, linked images
|
||||
/// are skipped, and one undo step makes them embedded again while the files stay.
|
||||
#[test]
|
||||
fn unembed_to_a_folder_writes_each_image_and_links_it_in_one_undo_step() {
|
||||
let dir = Folder::new("unembed-folder");
|
||||
let out = dir.file("out");
|
||||
for sub in ["a", "b", "out"] {
|
||||
std::fs::create_dir_all(dir.file(sub)).unwrap();
|
||||
}
|
||||
let (red, blue) = (png(60, 30, RED), png(40, 20, BLUE));
|
||||
write(&dir.file("a/photo.png"), &red);
|
||||
write(&dir.file("b/photo.png"), &blue);
|
||||
write(&dir.file("a/linked.png"), &red);
|
||||
let kept = b"not an image".to_vec();
|
||||
write(&file_in(&out, "photo.png"), &kept);
|
||||
let mut s = session();
|
||||
let a = place_embedded(&mut s, &dir.file("a/photo.png"));
|
||||
let b = place_embedded(&mut s, &dir.file("b/photo.png"));
|
||||
let linked = place(&mut s, &dir.file("a/linked.png"));
|
||||
let linked_path = image(&s, linked).link.unwrap().path;
|
||||
let (bounds_a, bounds_b) = (bounds(&s, a), bounds(&s, b));
|
||||
let undo_before = s.doc().unwrap().history.undo.len();
|
||||
let r = run(&mut s, "links.unembed", json!({"ids": [a.0, linked.0, b.0], "folder": out}));
|
||||
let (path_a, path_b) = (file_in(&out, "photo 2.png"), file_in(&out, "photo 3.png"));
|
||||
assert_eq!(r, json!({"unembedded": [{"id": a.0, "path": path_a}, {"id": b.0, "path": path_b}], "skipped": [linked.0]}));
|
||||
assert_eq!(files_in(&out), ["photo 2.png", "photo 3.png", "photo.png"]);
|
||||
assert_eq!(std::fs::read(file_in(&out, "photo.png")).unwrap(), kept, "a file already there is not replaced");
|
||||
assert_eq!(std::fs::read(&path_a).unwrap(), red);
|
||||
assert_eq!(std::fs::read(&path_b).unwrap(), blue);
|
||||
assert_eq!(image(&s, a).link.unwrap().path, path_a);
|
||||
assert_eq!(image(&s, b).link.unwrap().path, path_b);
|
||||
assert_eq!(image(&s, linked).link.unwrap().path, linked_path, "a linked image is left as it is");
|
||||
assert_eq!((bounds(&s, a), bounds(&s, b)), (bounds_a, bounds_b));
|
||||
assert_eq!(s.doc().unwrap().history.undo.len(), undo_before + 1, "one undo step");
|
||||
run(&mut s, "edit.undo", json!({}));
|
||||
assert!(image(&s, a).link.is_none() && image(&s, b).link.is_none(), "both embedded again");
|
||||
assert_eq!(files_in(&out).len(), 3, "undo leaves the files");
|
||||
// With no ids, the selected embedded images.
|
||||
s.doc_mut().unwrap().selection.objects = vec![b, linked];
|
||||
let r = run(&mut s, "links.unembed", json!({"folder": out}));
|
||||
assert_eq!(r, json!({"unembedded": [{"id": b.0, "path": file_in(&out, "photo 4.png")}], "skipped": []}));
|
||||
assert_eq!(std::fs::read(file_in(&out, "photo 4.png")).unwrap(), blue);
|
||||
}
|
||||
|
||||
/// A batch that fails part way writes no file and changes nothing; requests that don't fit the
|
||||
/// command are refused before anything is written.
|
||||
#[test]
|
||||
fn unembed_to_a_folder_that_fails_leaves_no_file_and_no_change() {
|
||||
let dir = Folder::new("unembed-folder-fail");
|
||||
let out = dir.file("out");
|
||||
std::fs::create_dir_all(&out).unwrap();
|
||||
write(&dir.file("one.png"), &png(60, 30, RED));
|
||||
write(&dir.file("two.png"), &png(60, 30, BLUE));
|
||||
let mut s = session();
|
||||
let a = place_embedded(&mut s, &dir.file("one.png"));
|
||||
let b = place_embedded(&mut s, &dir.file("two.png"));
|
||||
// The second image's pixels can't be read: the first one's file is removed again.
|
||||
let key = image(&s, b).key;
|
||||
let saved = s.doc().unwrap().doc.images.get(&key).cloned().unwrap();
|
||||
std::sync::Arc::make_mut(&mut s.doc_mut().unwrap().doc).images.insert(key.clone(), vectorcraft_doc::ImageBlob::png(png_header(60, 30)));
|
||||
let undo_before = s.doc().unwrap().history.undo.len();
|
||||
let e = s.execute("links.unembed", &json!({"ids": [a.0, b.0], "folder": out})).unwrap_err();
|
||||
assert!(e.to_string().ends_with("the image's pixels can't be read"), "{e}");
|
||||
assert!(files_in(&out).is_empty(), "no file left behind");
|
||||
assert!(image(&s, a).link.is_none() && image(&s, b).link.is_none());
|
||||
assert_eq!(s.doc().unwrap().history.undo.len(), undo_before);
|
||||
std::sync::Arc::make_mut(&mut s.doc_mut().unwrap().doc).images.insert(key, saved);
|
||||
|
||||
let refused = |s: &mut Session, p: Value| s.execute("links.unembed", &p).unwrap_err().to_string();
|
||||
let both = "give id and path for one image, or ids and folder for several";
|
||||
assert!(refused(&mut s, json!({"ids": [a.0, a.0], "folder": out})).ends_with("`ids` names an object twice"));
|
||||
assert!(refused(&mut s, json!({"id": a.0, "folder": out})).ends_with(both));
|
||||
assert!(refused(&mut s, json!({"ids": [a.0], "path": file_in(&out, "x.png")})).ends_with(both));
|
||||
assert!(refused(&mut s, json!({"ids": [a.0]})).ends_with("missing `folder`"));
|
||||
assert!(refused(&mut s, json!({"ids": [a.0], "folder": 5})).ends_with("`folder` must be a string"));
|
||||
assert!(refused(&mut s, json!({"ids": [], "folder": out})).ends_with("select an image"));
|
||||
let file = dir.file("one.png");
|
||||
assert!(refused(&mut s, json!({"ids": [a.0], "folder": file})).ends_with(&format!("{file} is not a folder")));
|
||||
run(&mut s, "shape.rectangle", json!({"x": 0, "y": 0, "width": 10, "height": 10}));
|
||||
let rect = s.doc().unwrap().selection.objects[0];
|
||||
assert!(refused(&mut s, json!({"ids": [a.0, rect.0], "folder": out})).ends_with(&format!("object {} is not an image", rect.0)));
|
||||
assert!(files_in(&out).is_empty(), "nothing written for a refused request");
|
||||
run(&mut s, "links.unembed", json!({"ids": [a.0], "folder": out}));
|
||||
assert!(refused(&mut s, json!({"ids": [a.0], "folder": out})).ends_with(&format!("image {} is linked already", a.0)));
|
||||
assert_eq!(files_in(&out), ["one.png"]);
|
||||
}
|
||||
|
||||
/// Under automation write roots, a folder outside them takes no file.
|
||||
#[test]
|
||||
fn unembed_to_a_folder_outside_the_write_roots_is_refused() {
|
||||
use crate::file_access::{AutomationRoots, confine};
|
||||
let dir = Folder::new("unembed-folder-roots");
|
||||
let (inside, outside) = (dir.file("inside"), dir.file("outside"));
|
||||
std::fs::create_dir_all(&inside).unwrap();
|
||||
std::fs::create_dir_all(&outside).unwrap();
|
||||
write(&file_in(&inside, "pic.png"), &png(60, 30, RED));
|
||||
let mut s = session();
|
||||
let id = place_embedded(&mut s, &file_in(&inside, "pic.png"));
|
||||
let roots = AutomationRoots::new(&[dir.0.as_path()], &[std::path::Path::new(&inside)]).unwrap();
|
||||
let p = json!({"ids": [id.0], "folder": outside});
|
||||
let e = confine(roots.as_ref(), || s.execute("links.unembed", &p)).unwrap_err().to_string();
|
||||
assert!(e.contains("outside the write root"), "{e}");
|
||||
assert!(files_in(&outside).is_empty());
|
||||
assert!(image(&s, id).link.is_none());
|
||||
let p = json!({"ids": [id.0], "folder": inside});
|
||||
confine(roots.as_ref(), || s.execute("links.unembed", &p)).unwrap();
|
||||
assert!(image(&s, id).link.is_some());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn go_to_selects_the_image() {
|
||||
let dir = Folder::new("goto");
|
||||
|
||||
@@ -6628,6 +6628,9 @@ liquify-list-end {0}, {1} {0} i {1}
|
||||
@msg Trap: select two or more objects filled with solid colours Trap: selecciona dos o més objectes emplenats amb colors sòlids
|
||||
@msg truncated truncat
|
||||
@msg Unembedded to {_1} S’ha desincrustat a {_1}
|
||||
@msgplural Unembedded {n} image to {folder}|Unembedded {n} images to {folder} S’ha desincrustat {n} imatge a {folder}|S’han desincrustat {n} imatges a {folder}
|
||||
@msg every numbered name for {name} is taken in that folder tots els noms numerats per a {name} estan ocupats en aquesta carpeta
|
||||
@msg give id and path for one image, or ids and folder for several indiqueu id i path per a una imatge, o ids i folder per a diverses
|
||||
@msg unknown command `{0}` ordre desconeguda `{0}`
|
||||
@msg step {step} of “{action}” runs the unknown command `{command}` el pas {step} de “{action}” executa l’ordre desconeguda `{command}`
|
||||
@msg unknown command `{0}`; did you mean `{1}`? ordre desconeguda `{0}`; volies dir `{1}`?
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -5636,6 +5636,9 @@ liquify-list-end {0}, {1} {0} a {1}
|
||||
@msg All colors are within the CMYK gamut Všechny barvy jsou v gamutu CMYK
|
||||
@msgplural {n} color is out of the CMYK gamut|{n} colors are out of the CMYK gamut {n} barva je mimo gamut CMYK|{n} barvy jsou mimo gamut CMYK|{n} barev je mimo gamut CMYK
|
||||
@msg Unembedded to {_1} Vložení zrušeno, uloženo do: {_1}
|
||||
@msgplural Unembedded {n} image to {folder}|Unembedded {n} images to {folder} Vložení zrušeno u {n} obrázku, uloženo do: {folder}|Vložení zrušeno u {n} obrázků, uloženo do: {folder}|Vložení zrušeno u {n} obrázků, uloženo do: {folder}
|
||||
@msg every numbered name for {name} is taken in that folder v této složce jsou obsazena všechna číslovaná jména pro {name}
|
||||
@msg give id and path for one image, or ids and folder for several zadejte id a path pro jeden obrázek, nebo ids a folder pro více obrázků
|
||||
@msg Reset {_1} Obnoveno: {_1}
|
||||
@msg Sent to {_1} Odesláno do {_1}
|
||||
@msg {_1} files Soubory {_1}
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -7742,6 +7742,9 @@ imageTrace Outline Kontur
|
||||
@msg All colors are within the CMYK gamut Alle farver er inden for CMYK-farveomfanget
|
||||
@msgplural {n} color is out of the CMYK gamut|{n} colors are out of the CMYK gamut {n} farve er uden for CMYK-farveomfanget|{n} farver er uden for CMYK-farveomfanget
|
||||
@msg Unembedded to {_1} Fjernede indlejring til {_1}
|
||||
@msgplural Unembedded {n} image to {folder}|Unembedded {n} images to {folder} Fjernede indlejring af {n} billede til {folder}|Fjernede indlejring af {n} billeder til {folder}
|
||||
@msg every numbered name for {name} is taken in that folder alle nummererede navne til {name} er optaget i den mappe
|
||||
@msg give id and path for one image, or ids and folder for several angiv id og path for ét billede, eller ids og folder for flere
|
||||
@msg Reset {_1} Nulstillede {_1}
|
||||
@msg Sent to {_1} Sendte til {_1}
|
||||
@msg {_1} files {_1}-filer
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -5237,6 +5237,9 @@ liquify-list-end {0}, {1} {0} und {1}
|
||||
@msg All colors are within the CMYK gamut Alle Farben liegen im CMYK-Farbumfang
|
||||
@msgplural {n} color is out of the CMYK gamut|{n} colors are out of the CMYK gamut {n} Farbe liegt außerhalb des CMYK-Farbumfangs|{n} Farben liegen außerhalb des CMYK-Farbumfangs
|
||||
@msg Unembedded to {_1} Einbettung aufgehoben, gespeichert unter {_1}
|
||||
@msgplural Unembedded {n} image to {folder}|Unembedded {n} images to {folder} Einbettung von {n} Bild aufgehoben, gespeichert unter {folder}|Einbettung von {n} Bildern aufgehoben, gespeichert unter {folder}
|
||||
@msg every numbered name for {name} is taken in that folder alle nummerierten Namen für {name} sind in diesem Ordner bereits vergeben
|
||||
@msg give id and path for one image, or ids and folder for several geben Sie id und path für ein Bild oder ids und folder für mehrere an
|
||||
@msg Reset {_1} {_1} zurückgesetzt
|
||||
@msg Sent to {_1} An {_1} gesendet
|
||||
@msg {_1} files {_1}-Dateien
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -5291,6 +5291,9 @@ digits Malayalam Μαλαγιάλαμ
|
||||
@msg All colors are within the CMYK gamut Όλα τα χρώματα βρίσκονται εντός της χρωματικής γκάμας CMYK
|
||||
@msgplural {n} color is out of the CMYK gamut|{n} colors are out of the CMYK gamut {n} χρώμα βρίσκεται εκτός της χρωματικής γκάμας CMYK|{n} χρώματα βρίσκονται εκτός της χρωματικής γκάμας CMYK
|
||||
@msg Unembedded to {_1} Καταργήθηκε η ενσωμάτωση στο {_1}
|
||||
@msgplural Unembedded {n} image to {folder}|Unembedded {n} images to {folder} Καταργήθηκε η ενσωμάτωση {n} εικόνας στο {folder}|Καταργήθηκε η ενσωμάτωση {n} εικόνων στο {folder}
|
||||
@msg every numbered name for {name} is taken in that folder όλα τα αριθμημένα ονόματα για το {name} χρησιμοποιούνται ήδη σε αυτόν τον φάκελο
|
||||
@msg give id and path for one image, or ids and folder for several δώστε id και path για μία εικόνα ή ids και folder για πολλές
|
||||
@msg Reset {_1} Επαναφορά {_1}
|
||||
@msg Sent to {_1} Στάλθηκε στο {_1}
|
||||
@msg {_1} files {_1} αρχεία
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -5344,6 +5344,9 @@ liquify-list-end {0}, {1} {0}, {1}
|
||||
@msg All colors are within the CMYK gamut Todos los colores están dentro de la gama CMYK
|
||||
@msgplural {n} color is out of the CMYK gamut|{n} colors are out of the CMYK gamut {n} color está fuera de la gama CMYK|{n} colores están fuera de la gama CMYK
|
||||
@msg Unembedded to {_1} Se desincrustó en {_1}
|
||||
@msgplural Unembedded {n} image to {folder}|Unembedded {n} images to {folder} Se desincrustó {n} imagen en {folder}|Se desincrustaron {n} imágenes en {folder}
|
||||
@msg every numbered name for {name} is taken in that folder todos los nombres numerados para {name} ya existen en esa carpeta
|
||||
@msg give id and path for one image, or ids and folder for several indique id y path para una imagen, o ids y folder para varias
|
||||
@msg Reset {_1} Se restableció {_1}
|
||||
@msg Sent to {_1} Se envió a {_1}
|
||||
@msg {_1} files {_1} archivos
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -5560,6 +5560,9 @@ liquify-list-end {0}, {1} {0} ja {1}
|
||||
@msg All colors are within the CMYK gamut Kaikki värit ovat CMYK-väriavaruuden sisällä
|
||||
@msgplural {n} color is out of the CMYK gamut|{n} colors are out of the CMYK gamut {n} väri on CMYK-väriavaruuden ulkopuolella|{n} väriä on CMYK-väriavaruuden ulkopuolella
|
||||
@msg Unembedded to {_1} Upotus purettiin kohteeseen {_1}
|
||||
@msgplural Unembedded {n} image to {folder}|Unembedded {n} images to {folder} Upotus purettiin {n} kuvalta kohteeseen {folder}|Upotus purettiin {n} kuvalta kohteeseen {folder}
|
||||
@msg every numbered name for {name} is taken in that folder kaikki kohteen {name} numeroidut nimet ovat jo käytössä siinä kansiossa
|
||||
@msg give id and path for one image, or ids and folder for several anna id ja path yhdelle kuvalle tai ids ja folder useammalle
|
||||
@msg Reset {_1} Palautettiin oletukseksi {_1}
|
||||
@msg Sent to {_1} Lähetettiin kohteeseen {_1}
|
||||
@msg {_1} files {_1}-tiedostot
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -5302,6 +5302,9 @@ liquify-list-end {0}, {1} {0} et {1}
|
||||
@msg All colors are within the CMYK gamut Toutes les couleurs sont dans la gamme CMJN
|
||||
@msgplural {n} color is out of the CMYK gamut|{n} colors are out of the CMYK gamut {n} couleur est hors de la gamme CMJN|{n} couleurs sont hors de la gamme CMJN
|
||||
@msg Unembedded to {_1} Incorporation annulée vers {_1}
|
||||
@msgplural Unembedded {n} image to {folder}|Unembedded {n} images to {folder} Incorporation annulée pour {n} image vers {folder}|Incorporation annulée pour {n} images vers {folder}
|
||||
@msg every numbered name for {name} is taken in that folder tous les noms numérotés pour {name} sont déjà pris dans ce dossier
|
||||
@msg give id and path for one image, or ids and folder for several indiquez id et path pour une image, ou ids et folder pour plusieurs
|
||||
@msg Reset {_1} {_1} réinitialisé
|
||||
@msg Sent to {_1} Envoyé à {_1}
|
||||
@msg {_1} files Fichiers {_1}
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -8697,6 +8697,9 @@ liquify-list-end {0}, {1} {0} और {1}
|
||||
@msg type that changes writing direction inside a text object opens in the direction of its first character टेक्स्ट ऑब्जेक्ट के भीतर लेखन दिशा बदलने वाला टेक्स्ट अपने पहले वर्ण की दिशा में खुलता है
|
||||
@msg type used as a mask in linked areas, wraparound text or a compound path doesn't clip लिंक्ड एरिया, रैपअराउंड टेक्स्ट या कंपाउंड पाथ में मास्क के रूप में इस्तेमाल किया गया टाइप क्लिप नहीं करता
|
||||
@msg Unembedded to {_1} एम्बेड हटाकर {_1} में रखा गया
|
||||
@msgplural Unembedded {n} image to {folder}|Unembedded {n} images to {folder} {n} इमेज का एम्बेड हटाकर {folder} में रखा गया|{n} इमेज का एम्बेड हटाकर {folder} में रखा गया
|
||||
@msg every numbered name for {name} is taken in that folder {name} के लिए हर नंबर वाला नाम उस फ़ोल्डर में पहले से लिया गया है
|
||||
@msg give id and path for one image, or ids and folder for several एक इमेज के लिए id और path दें, या कई के लिए ids और folder दें
|
||||
@msg unexpected host trap होस्ट में अप्रत्याशित ट्रैप
|
||||
@msg unexpected resources अप्रत्याशित संसाधन
|
||||
@msg unknown {k} key `{key}` (size, position) अज्ञात {k} कुंजी `{key}` (size, position)
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -6029,6 +6029,9 @@ liquify-list-end {0}, {1} {0} és {1}
|
||||
@msg tool shortcuts must be a single key (optionally with Shift) eszköz billentyűparancsa egyetlen billentyű lehet (Shifttel vagy anélkül)
|
||||
@msg truncated csonka
|
||||
@msg Unembedded to {_1} Beágyazás megszüntetve, ide: {_1}
|
||||
@msgplural Unembedded {n} image to {folder}|Unembedded {n} images to {folder} Beágyazás megszüntetve, képek: {n}, ide: {folder}
|
||||
@msg every numbered name for {name} is taken in that folder abban a mappában minden sorszámozott név foglalt: {name}
|
||||
@msg give id and path for one image, or ids and folder for several egy képhez adja meg az id és a path, többhöz az ids és a folder értékét
|
||||
@msg unknown command `{0}` ismeretlen parancs: `{0}`
|
||||
@msg step {step} of “{action}” runs the unknown command `{command}` „{action}”, lépés: {step}: ismeretlen parancsot futtat: `{command}`
|
||||
@msg unknown command `{0}`; did you mean `{1}`? ismeretlen parancs: `{0}`; erre gondolt: `{1}`?
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -5370,6 +5370,9 @@ liquify-list-end {0}, {1} {0} e {1}
|
||||
@msg All colors are within the CMYK gamut Tutti i colori rientrano nella gamma CMYK
|
||||
@msgplural {n} color is out of the CMYK gamut|{n} colors are out of the CMYK gamut {n} colore è fuori dalla gamma CMYK|{n} colori sono fuori dalla gamma CMYK
|
||||
@msg Unembedded to {_1} Incorporamento rimosso, salvato in {_1}
|
||||
@msgplural Unembedded {n} image to {folder}|Unembedded {n} images to {folder} Incorporamento rimosso per {n} immagine, salvata in {folder}|Incorporamento rimosso per {n} immagini, salvate in {folder}
|
||||
@msg every numbered name for {name} is taken in that folder tutti i nomi numerati per {name} sono già usati in quella cartella
|
||||
@msg give id and path for one image, or ids and folder for several indica id e path per un’immagine, oppure ids e folder per più immagini
|
||||
@msg Reset {_1} Reimpostato {_1}
|
||||
@msg Sent to {_1} Inviato a {_1}
|
||||
@msg {_1} files {_1} file
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -5439,6 +5439,9 @@ liquify-list-end {0}, {1} {0}、{1}
|
||||
@msg All colors are within the CMYK gamut すべてのカラーが CMYK の色域内です
|
||||
@msgplural {n} color is out of the CMYK gamut|{n} colors are out of the CMYK gamut {n} 個のカラーが CMYK の色域外です
|
||||
@msg Unembedded to {_1} 埋め込みを解除して {_1} に保存しました
|
||||
@msgplural Unembedded {n} image to {folder}|Unembedded {n} images to {folder} {n} 枚の画像の埋め込みを解除して {folder} に保存しました
|
||||
@msg every numbered name for {name} is taken in that folder そのフォルダーでは、{name} の番号付きの名前がすべて使われています
|
||||
@msg give id and path for one image, or ids and folder for several 1 つの画像には id と path を、複数の画像には ids と folder を指定してください
|
||||
@msg no swatch library `{l}` (see swatch.library.list) スウォッチライブラリ `{l}` が見つかりません (swatch.library.list を参照)
|
||||
@msg no user library folder here この環境にはユーザーライブラリフォルダーがありません
|
||||
@msg Couldn't place {name}: the document it was dropped on was closed {name} を配置できませんでした: ドロップ先のドキュメントは閉じられています
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -7004,6 +7004,9 @@ font-technology Variable ცვლადი
|
||||
@msg All colors are within the CMYK gamut ყველა ფერი CMYK-ის გამის ფარგლებშია
|
||||
@msgplural {n} color is out of the CMYK gamut|{n} colors are out of the CMYK gamut CMYK-ის გამის ფარგლებს გარეთაა ფერი ({n})
|
||||
@msg Unembedded to {_1} ჩაშენება მოხსნილია: {_1}
|
||||
@msgplural Unembedded {n} image to {folder}|Unembedded {n} images to {folder} ჩაშენება მოხსნილია, გამოსახულებები: {n}, საქაღალდე: {folder}
|
||||
@msg every numbered name for {name} is taken in that folder იმ საქაღალდეში {name}-ის ყველა დანომრილი სახელი დაკავებულია
|
||||
@msg give id and path for one image, or ids and folder for several ერთი გამოსახულებისთვის მიუთითეთ id და path, რამდენიმესთვის კი ids და folder
|
||||
@msg Reset {_1} ჩამოყრილია: {_1}
|
||||
@msg Sent to {_1} გაგზავნილია: {_1}
|
||||
@msg {_1} files ფაილები: {_1}
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -5366,6 +5366,9 @@ liquify-list-end {0}, {1} {0} 및 {1}
|
||||
@msg All colors are within the CMYK gamut 모든 색상이 CMYK 색상 범위 안에 있습니다
|
||||
@msgplural {n} color is out of the CMYK gamut|{n} colors are out of the CMYK gamut 색상 {n}개가 CMYK 색상 범위를 벗어났습니다
|
||||
@msg Unembedded to {_1} {_1}에 포함 해제했습니다
|
||||
@msgplural Unembedded {n} image to {folder}|Unembedded {n} images to {folder} 이미지 {n}개를 {folder}에 포함 해제했습니다
|
||||
@msg every numbered name for {name} is taken in that folder 해당 폴더에서 {name}을(를) 위한 번호 이름이 모두 사용 중입니다
|
||||
@msg give id and path for one image, or ids and folder for several 이미지 하나에는 id와 path를, 여러 개에는 ids와 folder를 지정하세요
|
||||
@msg no swatch library `{l}` (see swatch.library.list) 견본 라이브러리 `{l}`이(가) 없습니다(swatch.library.list 참조)
|
||||
@msg no user library folder here 여기에는 사용자 라이브러리 폴더가 없습니다
|
||||
@msg Couldn't place {name}: the document it was dropped on was closed {name}을(를) 가져올 수 없습니다: 놓은 문서가 닫혔습니다
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -5636,6 +5636,9 @@ imageTrace Outline Contour
|
||||
@msg All colors are within the CMYK gamut Alle kleuren vallen binnen het CMYK-gamut
|
||||
@msgplural {n} color is out of the CMYK gamut|{n} colors are out of the CMYK gamut {n} kleur valt buiten het CMYK-gamut|{n} kleuren vallen buiten het CMYK-gamut
|
||||
@msg Unembedded to {_1} Extern gemaakt: {_1}
|
||||
@msgplural Unembedded {n} image to {folder}|Unembedded {n} images to {folder} {n} afbeelding extern gemaakt in {folder}|{n} afbeeldingen extern gemaakt in {folder}
|
||||
@msg every numbered name for {name} is taken in that folder elke genummerde naam voor {name} is al vergeven in die map
|
||||
@msg give id and path for one image, or ids and folder for several geef id en path voor één afbeelding, of ids en folder voor meerdere
|
||||
@msg Reset {_1} {_1} opnieuw ingesteld
|
||||
@msg Sent to {_1} Verzonden naar {_1}
|
||||
@msg {_1} files {_1}-bestanden
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -5462,6 +5462,9 @@ liquify-list-end {0}, {1} {0} i {1}
|
||||
@msg All colors are within the CMYK gamut Wszystkie kolory mieszczą się w gamucie CMYK
|
||||
@msgplural {n} color is out of the CMYK gamut|{n} colors are out of the CMYK gamut {n} kolor nie mieści się w gamucie CMYK|{n} kolory nie mieszczą się w gamucie CMYK|{n} kolorów nie mieści się w gamucie CMYK
|
||||
@msg Unembedded to {_1} Wyodrębniono do {_1}
|
||||
@msgplural Unembedded {n} image to {folder}|Unembedded {n} images to {folder} Wyodrębniono {n} obraz do {folder}|Wyodrębniono {n} obrazy do {folder}|Wyodrębniono {n} obrazów do {folder}
|
||||
@msg every numbered name for {name} is taken in that folder wszystkie numerowane nazwy dla {name} są zajęte w tym folderze
|
||||
@msg give id and path for one image, or ids and folder for several podaj id i path dla jednego obrazu albo ids i folder dla kilku
|
||||
@msg Reset {_1} Zresetowano {_1}
|
||||
@msg Sent to {_1} Wysłano do {_1}
|
||||
@msg {_1} files Pliki {_1}
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -4643,6 +4643,9 @@ axis Both Ambos
|
||||
@msg All colors are within the CMYK gamut Todas as cores estão dentro do gamut CMYK
|
||||
@msgplural {n} color is out of the CMYK gamut|{n} colors are out of the CMYK gamut {n} cor está fora do gamut CMYK|{n} cores estão fora do gamut CMYK
|
||||
@msg Unembedded to {_1} Desincorporado para {_1}
|
||||
@msgplural Unembedded {n} image to {folder}|Unembedded {n} images to {folder} {n} imagem desincorporada para {folder}|{n} imagens desincorporadas para {folder}
|
||||
@msg every numbered name for {name} is taken in that folder todos os nomes numerados para {name} já existem nessa pasta
|
||||
@msg give id and path for one image, or ids and folder for several informe id e path para uma imagem, ou ids e folder para várias
|
||||
@msg Reset {_1} Redefinir {_1}
|
||||
@msg Sent to {_1} Enviado para {_1}
|
||||
@msg {_1} files {_1} arquivos
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -5368,6 +5368,9 @@ liquify-list-end {0}, {1} {0} и {1}
|
||||
@msg All colors are within the CMYK gamut Все цвета входят в цветовой охват CMYK
|
||||
@msgplural {n} color is out of the CMYK gamut|{n} colors are out of the CMYK gamut {n} цвет выходит за пределы цветового охвата CMYK|{n} цвета выходят за пределы цветового охвата CMYK|{n} цветов выходят за пределы цветового охвата CMYK
|
||||
@msg Unembedded to {_1} Извлечено в {_1}
|
||||
@msgplural Unembedded {n} image to {folder}|Unembedded {n} images to {folder} Извлечено {n} изображение в {folder}|Извлечено {n} изображения в {folder}|Извлечено {n} изображений в {folder}
|
||||
@msg every numbered name for {name} is taken in that folder все нумерованные имена для {name} уже заняты в этой папке
|
||||
@msg give id and path for one image, or ids and folder for several укажите id и path для одного изображения или ids и folder для нескольких
|
||||
@msg Reset {_1} Сброшено: {_1}
|
||||
@msg Sent to {_1} Отправлено в {_1}
|
||||
@msg {_1} files {_1} файлов
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -5232,6 +5232,9 @@ liquify-list-end {0}, {1} {0} och {1}
|
||||
@msg All colors are within the CMYK gamut Alla färger ligger inom CMYK-färgomfånget
|
||||
@msgplural {n} color is out of the CMYK gamut|{n} colors are out of the CMYK gamut {n} färg ligger utanför CMYK-färgomfånget|{n} färger ligger utanför CMYK-färgomfånget
|
||||
@msg Unembedded to {_1} Extraherad till {_1}
|
||||
@msgplural Unembedded {n} image to {folder}|Unembedded {n} images to {folder} Extraherade {n} bild till {folder}|Extraherade {n} bilder till {folder}
|
||||
@msg every numbered name for {name} is taken in that folder alla numrerade namn för {name} är upptagna i den mappen
|
||||
@msg give id and path for one image, or ids and folder for several ange id och path för en bild, eller ids och folder för flera
|
||||
@msg Reset {_1} Återställ {_1}
|
||||
@msg Sent to {_1} Skickat till {_1}
|
||||
@msg {_1} files {_1}-filer
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -5061,6 +5061,9 @@ liquify-list-end {0}, {1} {0} ve {1}
|
||||
@msg All colors are within the CMYK gamut Tüm renkler CMYK gamındadır
|
||||
@msgplural {n} color is out of the CMYK gamut|{n} colors are out of the CMYK gamut {n} renk CMYK gamının dışında
|
||||
@msg Unembedded to {_1} {_1}'ye gömülü değil
|
||||
@msgplural Unembedded {n} image to {folder}|Unembedded {n} images to {folder} {n} görselin gömülmesi kaldırıldı: {folder}
|
||||
@msg every numbered name for {name} is taken in that folder {name} için numaralandırılmış her ad o klasörde zaten kullanılıyor
|
||||
@msg give id and path for one image, or ids and folder for several tek görsel için id ve path, birden çok görsel için ids ve folder verin
|
||||
@msg Reset {_1} {_1}'yi sıfırla
|
||||
@msg Sent to {_1} {_1}'ye gönderildi
|
||||
@msg {_1} files {_1} dosyaları
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -5354,6 +5354,9 @@ liquify-list-end {0}, {1} {0} і {1}
|
||||
@msg All colors are within the CMYK gamut Усі кольори входять у колірне охоплення CMYK
|
||||
@msgplural {n} color is out of the CMYK gamut|{n} colors are out of the CMYK gamut {n} колір виходить за межі колірного охоплення CMYK|{n} кольори виходять за межі колірного охоплення CMYK|{n} кольорів виходять за межі колірного охоплення CMYK
|
||||
@msg Unembedded to {_1} Вилучено у {_1}
|
||||
@msgplural Unembedded {n} image to {folder}|Unembedded {n} images to {folder} Вилучено {n} зображення у {folder}|Вилучено {n} зображення у {folder}|Вилучено {n} зображень у {folder}
|
||||
@msg every numbered name for {name} is taken in that folder усі нумеровані імена для {name} уже зайняті в цій папці
|
||||
@msg give id and path for one image, or ids and folder for several укажіть id і path для одного зображення або ids і folder для кількох
|
||||
@msg Reset {_1} Скинуто: {_1}
|
||||
@msg Sent to {_1} Відправлено до {_1}
|
||||
@msg {_1} files {_1} файлів
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -5784,6 +5784,9 @@ liquify-list-end {0}, {1} {0} và {1}
|
||||
@msg tool shortcuts must be a single key (optionally with Shift) phím tắt công cụ phải là một phím đơn (tùy chọn với Shift)
|
||||
@msg truncated bị cắt ngắn
|
||||
@msg Unembedded to {_1} Đã bỏ nhúng vào {_1}
|
||||
@msgplural Unembedded {n} image to {folder}|Unembedded {n} images to {folder} Đã bỏ nhúng {n} ảnh vào {folder}
|
||||
@msg every numbered name for {name} is taken in that folder mọi tên đánh số cho {name} đã được dùng trong thư mục đó
|
||||
@msg give id and path for one image, or ids and folder for several hãy nhập id và path cho một ảnh, hoặc ids và folder cho nhiều ảnh
|
||||
@msg unknown command `{0}` lệnh không xác định `{0}`
|
||||
@msg step {step} of “{action}” runs the unknown command `{command}` bước {step} của “{action}” chạy lệnh không xác định `{command}`
|
||||
@msg unknown command `{0}`; did you mean `{1}`? lệnh không xác định `{0}`; ý bạn là `{1}`?
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 205 and column 5.
|
@@ -5116,6 +5116,9 @@ liquify-list-end {0}, {1} {0}和{1}
|
||||
@msg All colors are within the CMYK gamut 所有颜色皆在 CMYK 色域内
|
||||
@msgplural {n} color is out of the CMYK gamut|{n} colors are out of the CMYK gamut {n} 个颜色超出 CMYK 色域
|
||||
@msg Unembedded to {_1} 已取消嵌入到 {_1}
|
||||
@msgplural Unembedded {n} image to {folder}|Unembedded {n} images to {folder} 已将 {n} 张图像取消嵌入到 {folder}
|
||||
@msg every numbered name for {name} is taken in that folder 该文件夹中 {name} 的所有带编号的名称均已被占用
|
||||
@msg give id and path for one image, or ids and folder for several 单个图像请提供 id 和 path,多个图像请提供 ids 和 folder
|
||||
@msg no swatch library `{l}` (see swatch.library.list) 没有色板库 `{l}` (请参阅 swatch.library.list)
|
||||
@msg no user library folder here 此处没有用户库文件夹
|
||||
@msg Couldn't place {name}: the document it was dropped on was closed 无法置入 {name}:将它拖放到的文档已关闭
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2749,6 +2749,9 @@ liquify-list-end {0}, {1} {0}和{1}
|
||||
@msg All colors are within the CMYK gamut 所有顏色皆在 CMYK 色域內
|
||||
@msgplural {n} color is out of the CMYK gamut|{n} colors are out of the CMYK gamut {n} 個顏色超出 CMYK 色域
|
||||
@msg Unembedded to {_1} 已取消內嵌至 {_1}
|
||||
@msgplural Unembedded {n} image to {folder}|Unembedded {n} images to {folder} 已將 {n} 個影像取消內嵌至 {folder}
|
||||
@msg every numbered name for {name} is taken in that folder 該資料夾中 {name} 的所有編號名稱都已被使用
|
||||
@msg give id and path for one image, or ids and folder for several 單一影像請提供 id 和 path,多個影像請提供 ids 和 folder
|
||||
@msg no swatch library `{l}` (see swatch.library.list) 沒有色票資料庫 `{l}` (請參閱 swatch.library.list)
|
||||
@msg no user library folder here 此處沒有使用者資料庫資料夾
|
||||
@msg Couldn't place {name}: the document it was dropped on was closed 無法置入 {name}:放置它的文件已關閉
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -335,6 +335,37 @@ pub(crate) fn unembed(app: &mut VectorcraftApp, id: u64, name: &str) {
|
||||
});
|
||||
}
|
||||
|
||||
/// Whether Unembed… can act on `embedded` selected embedded images: one goes to a picked file,
|
||||
/// several to a picked folder (the web downloads each one).
|
||||
pub(crate) fn can_unembed(app: &VectorcraftApp, embedded: usize) -> bool {
|
||||
match embedded {
|
||||
0 => false,
|
||||
1 => true,
|
||||
_ => app.services.download.is_some() || app.services.pick_folder.is_some(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Write embedded images `ids` to new files in a picked folder and link each one to its file, in
|
||||
/// one undo step (the web downloads each one and links none).
|
||||
pub(crate) fn unembed_several(app: &mut VectorcraftApp, ids: Vec<u64>) {
|
||||
if app.services.download.is_some() {
|
||||
for id in ids {
|
||||
unembed(app, id, "");
|
||||
}
|
||||
return;
|
||||
}
|
||||
crate::picks::button(app, move |app| unembed_to_picked_folder(app, ids.clone()));
|
||||
}
|
||||
|
||||
fn unembed_to_picked_folder(app: &mut VectorcraftApp, ids: Vec<u64>) {
|
||||
let Some(folder) = crate::picks::folder(app) else { return };
|
||||
let r = app.run("links.unembed", json!({ "ids": ids, "folder": folder }));
|
||||
report(app, r, |v| {
|
||||
let n = v["unembedded"].as_array().map_or(0, Vec::len);
|
||||
crate::i18n::msg_n(n as u64, "Unembedded {n} image to {folder}", "Unembedded {n} images to {folder}", &[("folder", &folder)])
|
||||
});
|
||||
}
|
||||
|
||||
/// The UI commands `links.editOriginal` (open the linked file in its app) and `links.reveal`
|
||||
/// (show it in its folder) for image `id` (default: the selected linked image) → `{path}`.
|
||||
pub(crate) fn open_file(app: &mut VectorcraftApp, p: &Value, reveal: bool) -> Result<Value, String> {
|
||||
@@ -834,12 +865,16 @@ pub fn menu(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
}
|
||||
});
|
||||
}
|
||||
if menu_item(ui, tl!("Unembed…"), embedded.len() == 1, false)
|
||||
&& let Some(r) = embedded.first()
|
||||
&& let Some(id) = r["id"].as_u64()
|
||||
{
|
||||
let name = r["name"].as_str().unwrap_or("Image").to_string();
|
||||
unembed(app, id, &name);
|
||||
if menu_item(ui, tl!("Unembed…"), can_unembed(app, embedded.len()), false) {
|
||||
match &embedded[..] {
|
||||
[r] => {
|
||||
if let Some(id) = r["id"].as_u64() {
|
||||
let name = r["name"].as_str().unwrap_or("Image").to_string();
|
||||
unembed(app, id, &name);
|
||||
}
|
||||
}
|
||||
rows => unembed_several(app, rows.iter().filter_map(|r| r["id"].as_u64()).collect()),
|
||||
}
|
||||
}
|
||||
if menu_item(ui, tl!("Placement Options…"), any, false) {
|
||||
crate::menus::invoke(app, "ui.placementOptionsDialog", json!({ "ids": ids(&sel, |_| true) }));
|
||||
|
||||
@@ -500,6 +500,36 @@ fn properties_shows_the_selected_image_and_its_link_actions() {
|
||||
assert!(text.contains("Linked File") && text.contains("Edit Original") && text.contains("Embed"), "{text}");
|
||||
}
|
||||
|
||||
/// Unembed… acts on several selected embedded images: it asks for one folder, writes a file for
|
||||
/// each image there and links each one to its file; with no folder picked, nothing changes.
|
||||
#[test]
|
||||
fn unembed_writes_several_images_to_one_picked_folder() {
|
||||
let dir = Folder::new("unembed-several");
|
||||
let (mut app, _, embedded) = app(&dir);
|
||||
let c = dir.file("other.png", &png(30, 10));
|
||||
let other = app.run("file.place", json!({"path": c, "at": [50, 50], "link": false})).unwrap()["ids"][0].as_u64().unwrap();
|
||||
assert!(super::links::can_unembed(&app, 1));
|
||||
assert!(!super::links::can_unembed(&app, 0));
|
||||
assert!(!super::links::can_unembed(&app, 2), "no folder to pick");
|
||||
let out = dir.0.join("out");
|
||||
std::fs::create_dir_all(&out).unwrap();
|
||||
// No folder picked: nothing written or linked.
|
||||
app.services.pick_folder = Some(Box::new(|| None));
|
||||
assert!(super::links::can_unembed(&app, 2));
|
||||
super::links::unembed_several(&mut app, vec![embedded, other]);
|
||||
assert_eq!(std::fs::read_dir(&out).unwrap().count(), 0);
|
||||
assert_eq!(app.run("links.info", json!({"id": embedded})).unwrap()["status"], "embedded");
|
||||
let picked = out.to_string_lossy().into_owned();
|
||||
let answer = picked.clone();
|
||||
app.services.pick_folder = Some(Box::new(move || Some(answer.clone())));
|
||||
super::links::unembed_several(&mut app, vec![embedded, other]);
|
||||
for (id, name) in [(embedded, "embedded.png"), (other, "other.png")] {
|
||||
let info = app.run("links.info", json!({"id": id})).unwrap();
|
||||
assert_eq!(info["path"], out.join(name).to_string_lossy().as_ref(), "{info}");
|
||||
}
|
||||
assert_eq!(app.ui.status, format!("Unembedded 2 images to {picked}"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_links_menu_items_run_commands() {
|
||||
let tree = crate::menus::menu_tree();
|
||||
|
||||
+11
@@ -8278,6 +8278,16 @@ every object in the layers each time the list is read. A `dcsTransparency` that
|
||||
returns `{id, onCanvas: false, owner}`, and the panel says the link has no place on the canvas. `links.embed {ids?}` keeps linked files' pixels in the document (an image whose
|
||||
file is missing stays linked: relink it first); `links.unembed {id, path}` writes an embedded image to a file
|
||||
(another extension converts it) and links to it, and without `path` returns `{name, dataBase64}`.
|
||||
`links.unembed {ids?, folder}` writes each embedded image of `ids` (default: the selected embedded images) to a new
|
||||
file in `folder`, in the format it is stored in (as PNG when that format is not one of VectorCraft's raster file formats), and links each image to its file, keeping its bounds, in one undo
|
||||
step; undo does not remove the files. A file is named after its image, with each character a file name can't hold
|
||||
(`/ \ : * ? " < > |` and control characters) as `_` and `Image` when nothing is left; when the name is taken it is
|
||||
`Name 2.png` … `Name 99.png`, and a file already in the folder is never replaced. Linked images among `ids` are left
|
||||
as they are and listed in `skipped`. It returns `{unembedded: [{id, path}], skipped}`. When an image can't be written,
|
||||
the files the call wrote are removed and the document does not change. A folder outside the automation write roots,
|
||||
`id` or `path` given with `ids` or `folder`, an id given twice, and `ids` with no embedded image are errors. The Links
|
||||
panel menu's Unembed… with several embedded images selected asks for one folder and runs this form (on the web it
|
||||
downloads each image instead and links none).
|
||||
`links.placementOptions {ids?, preserve?: transforms|bounds|fileDimensions|fit|fill, align?: topLeft…bottomRight,
|
||||
clip?}` decides how a relinked or updated file takes an image's place (default `bounds`: stretched into the old
|
||||
bounds; `clip` puts it in a clip group of the old bounds when it is larger). The UI commands `links.editOriginal` and
|
||||
@@ -8296,6 +8306,7 @@ malformed `ids`, or nothing to copy is an error, and the clipboard is left as it
|
||||
{"name":"run_command","arguments":{"command":"links.list","params":{"show":"missing"}}}
|
||||
{"name":"run_command","arguments":{"command":"links.placementOptions","params":{"ids":[12],"preserve":"fit","align":"top"}}}
|
||||
{"name":"run_command","arguments":{"command":"links.unembed","params":{"id":14,"path":"/tmp/logo.png"}}}
|
||||
{"name":"run_command","arguments":{"command":"links.unembed","params":{"ids":[14,15],"folder":"/tmp/images"}}}
|
||||
```
|
||||
|
||||
## Package and Document Info
|
||||
|
||||
@@ -2022,6 +2022,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur
|
||||
- Missing linked files can be looked for in a folder and its subfolders: Find in Folder… in the Linked File Not Found dialog and in the Links panel menu lists the files with each one's name, those with the size and contents saved with the link first, and relinks the files chosen, copying an image's file into the document's folder when asked, without replacing a file there (`links.findFiles`, `links.relink {copy}`). In the Links panel it looks for the selected linked files when any are selected.
|
||||
- The Links panel's Relink… opens a Relink dialog whose Replace menu picks which links take the new file: Selected Instances (the selected images, as before), All Instances (every image linked to the same file), Missing Links from This Folder (then every other missing link whose file name is in the new file's folder) and Each Link Separately (a file for each selected link in turn). Each relinks as one undo step (`links.relink {scope}`, `ui.relinkDialog`). Relink to Folder… stays as it is.
|
||||
- The Links panel menu's Copy Info ([Links panel](https://helpx.adobe.com/illustrator/desktop/add-and-import-files/import-from-other-apps/links-panel-in-illustrator.html)) copies the selected link's file name to the clipboard (`links.copyInfo`). VectorCraft's own rules: with several rows selected it copies one name per line in the order the panel shows them, an embedded image gives the name its row shows, and the item is off with no row selected.
|
||||
- The Links panel menu's Unembed… works on several selected embedded images at once and writes them all to one chosen folder ([Embed and unembed images and files](https://helpx.adobe.com/illustrator/desktop/add-and-import-files/manage-linked-and-embedded-files/embed-images-and-files.html)): it asks for a folder once, writes a file for each image there and links each image to its file in one undo step (`links.unembed {ids, folder}`). VectorCraft's own rules: each file keeps the format its image is stored in (or PNG when that format is not one of VectorCraft's raster file formats) and is named after the image, a taken name gets a number (`Name 2`) and a file already in the folder is never replaced, linked rows in the selection are left as they are, and when one image can't be written the files already written are removed and nothing is unembedded. On the web each image is downloaded instead. Evidence: `unembed_to_a_folder_writes_each_image_and_links_it_in_one_undo_step`, `unembed_to_a_folder_that_fails_leaves_no_file_and_no_change`, `unembed_writes_several_images_to_one_picked_folder`.
|
||||
- Linked files inside symbols, graph designs, patterns and opacity masks are saved with their paths relative to the document, as linked files in the layers are, so they are found after the document and its files move to another folder together; on open each of those links takes the path where its file was found. Update Links, and opening with Update Links: Automatically, read a modified file again for that art too, and saving a document refreshes its placed copies inside symbols and patterns of the other open documents. Evidence: `links_outside_the_layers_find_their_files_after_the_folder_moves`, `update_links_reads_files_again_inside_symbols_patterns_and_masks`, `saving_a_document_refreshes_its_placed_copies_inside_symbols_and_patterns`.
|
||||
- A linked file that is missing when a moved document is saved keeps the folder its relative path names, instead of a relative path worked out from the out-of-date absolute path, also for a `.ai` file another app wrote (such as `src/`), so the file is found once it is back in that folder. Evidence: `a_missing_link_keeps_its_relative_path_when_the_moved_document_is_saved`, `links_of_an_imported_file_are_found_by_their_relative_folder`, `a_missing_link_of_a_moved_document_keeps_its_relative_place`.
|
||||
- On Windows, a document opened from a mapped network drive finds its links stored with the share's own path (`\\server\share\…`), as the same document opened from the share does; links on other computers stay missing.
|
||||
|
||||
Reference in New Issue
Block a user