Skip to content

Commit 4c5b870

Browse files
Save PDFs and SVGs with content hash
1 parent 80151e3 commit 4c5b870

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

apple-catalog-parsing/native/swift/AssetCatalogParser/Sources/AssetCatalogParser/AssetCatalogReader.swift

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,15 @@ enum AssetUtil {
223223
// Get image dimensions from regular rendition
224224
(width, height, unslicedImage) = resolveImageDimensions(rendition, isVector)
225225

226-
// Skip SVGs, but save images even if they don't have an extension (default to png)
227-
if fileExtension != "svg", let unslicedImage = unslicedImage {
226+
// Handle PDFs and SVGs by saving raw data
227+
if fileExtension == "pdf" || fileExtension == "svg" {
228+
let fileURL = try! createResultsPath(assetURL: file, outputURL: outputURL)
229+
.appendingPathComponent(imageId)
230+
.appendingPathExtension(fileExtension)
231+
try! data.write(to: fileURL)
232+
}
233+
// Save images that can be converted to CGImage
234+
else if let unslicedImage = unslicedImage {
228235
let format = fileExtension.isEmpty ? "png" : fileExtension
229236
images[imageId] = (cgImage: unslicedImage, format: format)
230237
}

0 commit comments

Comments
 (0)