Skip to content

armgit / Filee

Public Imported from GitHub
0

Free, open-source file converter. Convert 263 formats offline by drag & drop — images, PDF, Word, Excel, PowerPoint, HWP/HWPX, video, audio, e-books and archives. No upload, no Office needed.

Merge origin/main into feat/live-motion-photo

KnifeLemon304ee332a396
diff --cc src/Filee.App/Services/PresetAvailability.cs
index d8b130f1,0859cefa..a70d59f4
--- a/src/Filee.App/Services/PresetAvailability.cs
+++ b/src/Filee.App/Services/PresetAvailability.cs
@@@ -36,11 -47,10 +47,11 @@@ public sealed class PresetAvailability(
if (merge && f.Id == "pdf" && !turns)
return true; // merged as it is
var frames = preset.SavesFramesOf(f.Id);
+ var motion = preset.ExtractsMotionOf(f.Id);
if (!turns)
- return planner.CanConvert(f.Id, target, frames, motion);
- return planner.CanConvert(f.Id, target, frames);
++ return planner.CanConvert(f.Id, target, frames, motionPhoto: motion);
// Rotate / flip: a route only counts when an engine on it turns images (not a PDF or a video copied).
- if (planner.Plan(f.Id, target, frames, motion) is not { } route)
- if (planner.Plan(f.Id, target, frames) is not { } route)
++ if (planner.Plan(f.Id, target, frames, motionPhoto: motion) is not { } route)
return false;
if (route.FirstTransformStep() >= 0)
return true;
diff --cc src/Filee.App/ViewModels/PresetEditorViewModel.cs
index 2dbb9ca7,446dcd31..90aac1ec
--- a/src/Filee.App/ViewModels/PresetEditorViewModel.cs
+++ b/src/Filee.App/ViewModels/PresetEditorViewModel.cs
@@@ -398,18 -391,19 +400,19 @@@ public sealed partial class PresetEdito
private bool TargetIsLossyMedia => TargetIsVideo
|| (TargetIsAudio && !LosslessAudioTargets.Contains(TargetId) && MediaCodecs.Effective(TargetId, _audioCodecValue) != AudioCodec.Alac);
- public bool ShowImage => TargetIsImage && !ShowLivePhoto;
+ /// <summary>A tool (Crop) keeps the source as it is: none of the image options apply.</summary>
- public bool ShowImage => !IsTool && TargetIsImage;
++ public bool ShowImage => !IsTool && TargetIsImage && !ShowLivePhoto;
/// <summary>Images and PDFs (pictures placed on pages) can be turned and flipped.</summary>
- private bool CanTurn => TargetIsImage || TargetId == "pdf";
+ private bool CanTurn => (TargetIsImage && !ShowLivePhoto) || TargetId == "pdf";
/// <summary>Rotate and flip for a PDF target, which has no image card to show them in.</summary>
public bool ShowTurnForPdf => TargetId == "pdf";
- public bool ShowQuality => TargetId == BuiltInData.SameAsSource || LossyTargets.Contains(TargetId);
+ public bool ShowQuality => !IsTool && (TargetId == BuiltInData.SameAsSource || LossyTargets.Contains(TargetId));
public bool ShowTiff => TargetId is "tiff" or BuiltInData.SameAsSource;
public bool ShowWebp => TargetId is "webp" or BuiltInData.SameAsSource;
public bool ShowMultiPageTiff => TargetId is "tiff";
public bool ShowIco => TargetId == "ico";
/// <summary>PDF options (also used when a PDF source becomes images) mean nothing for media, archive, font, subtitle, data, e-mail and 3D targets.</summary>
- public bool ShowPdf => !ShowLivePhoto && TargetCategory is not (FormatCategory.Video or FormatCategory.Audio or FormatCategory.Archive or FormatCategory.Font
- public bool ShowPdf => !IsTool && TargetCategory is not (FormatCategory.Video or FormatCategory.Audio or FormatCategory.Archive or FormatCategory.Font
++ public bool ShowPdf => !IsTool && !ShowLivePhoto && TargetCategory is not (FormatCategory.Video or FormatCategory.Audio or FormatCategory.Archive or FormatCategory.Font
or FormatCategory.Subtitle or FormatCategory.Data or FormatCategory.Model3D) && TargetId != "eml";
public bool ShowPdfBuild => TargetId == "pdf";
public bool ShowPdfSplit => TargetId == "pdf";
diff --cc src/Filee.Core/Conversion/IConverter.cs
index 9ddf6a04,a81b3c25..009f728e
--- a/src/Filee.Core/Conversion/IConverter.cs
+++ b/src/Filee.Core/Conversion/IConverter.cs
@@@ -30,12 -30,17 +30,18 @@@ namespace Filee.Core.Conversion
/// <param name="FrameSequence">
/// The edge writes every frame of a video as numbered pictures into a folder (<see cref="Presets.MediaOptions.SaveEveryFrame"/>).
/// It is never part of an ordinary route (a video → JPG stays one still frame), and with
- /// <see cref="RoutePlanner.Plan"/> asking for frames it is the whole route.
-/// <see cref="RoutePlanner.Plan(string, string, bool, bool)"/> asking for frames it is the whole route.
++/// <see cref="RoutePlanner.Plan(string, string, bool, bool, bool)"/> asking for frames it is the whole route.
+ /// </param>
+ /// <param name="Unshaped">
+ /// The engine draws text one character after the other, left to right, without complex-script shaping (no joined
+ /// Arabic letters, no right-to-left order, no reordered vowel signs, conjuncts or placed marks). A source whose text
+ /// needs shaping is never routed through the edge: <see cref="JobQueue"/> asks the engine
+ /// (<see cref="ITextShapingCheck"/>) and plans again without it.
/// </param>
+/// <param name="MotionPhoto">Only taken when explicitly extracting a camera image's motion; never a still-image route.</param>
public readonly record struct ConversionEdge(
string From, string To, int Cost = 10, bool ImageSourcesOnly = false, bool NotForImageSources = false,
- bool DirectOnly = false, bool FrameSequence = false, bool MotionPhoto = false);
- bool DirectOnly = false, bool FrameSequence = false, bool Unshaped = false);
++ bool DirectOnly = false, bool FrameSequence = false, bool Unshaped = false, bool MotionPhoto = false);
/// <summary>
/// A conversion an engine refuses with a reason the user can act on, shown in their language (the file's
diff --cc src/Filee.Core/Conversion/JobQueue.cs
index 15d1706a,03aa3dc0..247d6e3a
--- a/src/Filee.Core/Conversion/JobQueue.cs
+++ b/src/Filee.Core/Conversion/JobQueue.cs
@@@ -351,8 -371,8 +371,9 @@@ public sealed class JobQueue : IAsyncDi
// "Save every frame": a video becomes a folder of pictures in one step of its own. Never for an intermediate
// file, and never on the way to another format (video → JPG is otherwise one still frame).
- var route = planner.Plan(source.Id, target, frames: finalOutput && job.Preset.SavesFramesOf(source.Id),
- motionPhoto: finalOutput && job.Preset.ExtractsMotionOf(source.Id));
+ var frames = finalOutput && job.Preset.SavesFramesOf(source.Id);
- var route = planner.Plan(source.Id, target, frames);
++ var motionPhoto = finalOutput && job.Preset.ExtractsMotionOf(source.Id);
++ var route = planner.Plan(source.Id, target, frames, motionPhoto: motionPhoto);
if (route is null)
return Fail(file, "error.no_route", $"{source.Id} → {target}");
diff --cc src/Filee.Core/Conversion/RoutePlanner.cs
index e23083d1,af7e5691..35bc8617
--- a/src/Filee.Core/Conversion/RoutePlanner.cs
+++ b/src/Filee.Core/Conversion/RoutePlanner.cs
@@@ -57,8 -58,10 +58,11 @@@ public sealed class RoutePlanne
/// <see cref="ConversionEdge.FrameSequence"/> edge from <paramref name="from"/> to <paramref name="to"/>, or none.
/// Without it those edges are never taken.
/// </param>
+ /// <param name="shaping">
+ /// The source has text that needs complex-script shaping: <see cref="ConversionEdge.Unshaped"/> edges are left out.
+ /// </param>
- public Route? Plan(string from, string to, bool frames = false, bool shaping = false)
+ /// <param name="motionPhoto">Extract motion from a camera image through a dedicated direct edge.</param>
- public Route? Plan(string from, string to, bool frames = false, bool motionPhoto = false)
++ public Route? Plan(string from, string to, bool frames = false, bool shaping = false, bool motionPhoto = false)
{
from = from.ToLowerInvariant();
to = to.ToLowerInvariant();
@@@ -107,8 -110,9 +111,9 @@@
foreach (var (converter, edge, edgeCost) in EdgesFrom(node))
{
- if (edge.To == edge.From || edge.FrameSequence
+ if (edge.To == edge.From || edge.FrameSequence || edge.MotionPhoto
|| (edge.ImageSourcesOnly && !imageSource) || (edge.NotForImageSources && imageSource)
+ || (edge.Unshaped && shaping)
|| (edge.DirectOnly && (node != from || edge.To != to)))
continue;
var next = cost + edgeCost;
@@@ -134,7 -138,7 +139,8 @@@
/// <summary>True if <paramref name="from"/> can be converted to <paramref name="to"/>.</summary>
/// <param name="frames">Every frame of a video as pictures (see <see cref="Plan"/>).</param>
- public bool CanConvert(string from, string to, bool frames = false, bool motionPhoto = false) => Plan(from, to, frames, motionPhoto) is not null;
- public bool CanConvert(string from, string to, bool frames = false) => Plan(from, to, frames) is not null;
++ public bool CanConvert(string from, string to, bool frames = false, bool motionPhoto = false) =>
++ Plan(from, to, frames, motionPhoto: motionPhoto) is not null;
private IReadOnlyList<(IConverter Converter, ConversionEdge Edge, int Cost)> EdgesFrom(string format) =>
_edgesFrom.TryGetValue(format, out var edges) ? edges : [];
diff --cc src/Filee.Core/Presets/Preset.cs
index 2017d09c,ee1645fa..1bede141
--- a/src/Filee.Core/Presets/Preset.cs
+++ b/src/Filee.Core/Presets/Preset.cs
@@@ -130,11 -136,10 +136,15 @@@ public sealed class Prese
&& MediaOptions.FrameTargets.Contains(TargetFormat)
&& Formats.FormatRegistry.FindById(sourceFormat)?.Category == Formats.FormatCategory.Video;
+ /// <summary>Explicitly extract motion from a camera image instead of making a video of its still image.</summary>
+ public bool ExtractsMotionOf(string sourceFormat) => Media.ExtractMotionPhoto
+ && TargetFormat is "mp4" or "mov"
+ && Formats.FormatRegistry.FindById(sourceFormat)?.Category == Formats.FormatCategory.Image;
+
+ /// <summary>True for a <see cref="PresetKind.Tool"/>.</summary>
+ [JsonIgnore]
+ public bool IsTool => Kind == PresetKind.Tool;
+
/// <summary>Creates a new random preset id.</summary>
public static string NewId() => Guid.NewGuid().ToString("N")[..12];