[O] Use correct id

This commit is contained in:
2025-10-26 12:34:52 +08:00
parent 6f2037a9dc
commit 024158fd1b
2 changed files with 4 additions and 4 deletions
@@ -120,7 +120,7 @@ fun FileListerScreen(modifier: Modifier = Modifier) {
try { try {
val templateStream = context.resources.openRawResource(R.raw.postcard4) val templateStream = context.resources.openRawResource(R.raw.postcard4)
val template = BufferedReader(InputStreamReader(templateStream)).readText() val template = BufferedReader(InputStreamReader(templateStream)).readText()
val svg = genSvg(template, latestImage.absolutePath) val (svg, exif) = genSvg(template, latestImage.absolutePath)
picture = renderSvgAndroid(context, svg) picture = renderSvgAndroid(context, svg)
// Save picture to file // Save picture to file
@@ -133,7 +133,7 @@ fun FileListerScreen(modifier: Modifier = Modifier) {
feedbackText = "Rendered ${latestImage.name}, now uploading..." feedbackText = "Rendered ${latestImage.name}, now uploading..."
val response = backendClient.uploadImage( val response = backendClient.uploadImage(
id = UUID.randomUUID().toString(), id = exif.urlName,
ownerKey = "1234", ownerKey = "1234",
originalPhoto = latestImage, originalPhoto = latestImage,
editedPhoto = renderedImageFile editedPhoto = renderedImageFile
@@ -21,7 +21,7 @@ fun createQRCode(url: String) =
QRCode.ofSquares().withSize(5).withMargin(0).withErrorCorrectionLevel(ErrorCorrectionLevel.LOW) QRCode.ofSquares().withSize(5).withMargin(0).withErrorCorrectionLevel(ErrorCorrectionLevel.LOW)
.withInnerSpacing(0).build(url).render() .withInnerSpacing(0).build(url).render()
suspend fun genSvg(template: String, imagePath: String): String { suspend fun genSvg(template: String, imagePath: String): Pair<String, ExifResult> {
var svg = template var svg = template
// Read target image's EXIF data // Read target image's EXIF data
@@ -41,7 +41,7 @@ suspend fun genSvg(template: String, imagePath: String): String {
"""<image id=\"_Image1\" width=\"${exif.w}px\" height=\"${exif.h}px\" xlink:href=\"data:image/jpeg;base64,${Base64.getEncoder().encodeToString(imageData)}\"/>""") """<image id=\"_Image1\" width=\"${exif.w}px\" height=\"${exif.h}px\" xlink:href=\"data:image/jpeg;base64,${Base64.getEncoder().encodeToString(imageData)}\"/>""")
.replace("""<image id="_Image3" width="100px" height="100px" xlink:href="data:image/png;base64,.*?"/>""".toRegex(), .replace("""<image id="_Image3" width="100px" height="100px" xlink:href="data:image/png;base64,.*?"/>""".toRegex(),
"""<image id=\"_Image3\" width=\"100px\" height=\"100px\" xlink:href=\"data:image/png;base64,${Base64.getEncoder().encodeToString(stream.toByteArray())}\"/>""") """<image id=\"_Image3\" width=\"100px\" height=\"100px\" xlink:href=\"data:image/png;base64,${Base64.getEncoder().encodeToString(stream.toByteArray())}\"/>""")
return svg return svg to exif
} }
class FontResolver(private val context: Context) : SVGExternalFileResolver() { class FontResolver(private val context: Context) : SVGExternalFileResolver() {