feat: use JSON for image metadata format

This commit is contained in:
Natsumi
2023-02-15 01:37:04 +13:00
parent c46c97e51a
commit edba9f6468
4 changed files with 82 additions and 54 deletions

View File

@@ -635,26 +635,21 @@ namespace VRCX
}
}
public void AddScreenshotMetadata(string path, string worldName, string worldId, bool changeFilename = false)
public void AddScreenshotMetadata(string path, string metadataString, string worldId, bool changeFilename = false)
{
try
var fileName = Path.GetFileNameWithoutExtension(path);
if (!File.Exists(path) || !path.EndsWith(".png") || !fileName.StartsWith("VRChat_"))
return;
if (changeFilename)
{
string fileName = Path.GetFileNameWithoutExtension(path);
if (!File.Exists(path) || !path.EndsWith(".png") || !fileName.StartsWith("VRChat_")) return;
if (changeFilename)
{
var newFileName = $"{fileName}_{worldId}";
var newPath = Path.Combine(Path.GetDirectoryName(path), newFileName + Path.GetExtension(path));
File.Move(path, newPath);
path = newPath;
}
string metadataString = $"{Program.Version}||{worldId}||{worldName}";
ScreenshotHelper.WritePNGDescription(path, metadataString);
var newFileName = $"{fileName}_{worldId}";
var newPath = Path.Combine(Path.GetDirectoryName(path), newFileName + Path.GetExtension(path));
File.Move(path, newPath);
path = newPath;
}
catch { }
ScreenshotHelper.WritePNGDescription(path, metadataString);
}
}
}