QuickLook Thumbnailing

RSS for tag

Generate thumbnails for common file types and add a Thumbnail Extension to your app using QuickLook Thumbnailing.

QuickLook Thumbnailing Documentation

Posts under QuickLook Thumbnailing tag

9 Posts
Sort by:
Post marked as solved
1 Replies
256 Views
Hi folks, My app is reading proprietary files with the file name extension .JPX - which is out of my control. In addition I’m providing QuickLook and Thumbnail extensions, used system-wide and in my app. Unfortunately iOS is assigning the JPEG-2000 file type (UTI „public.jpeg-2000“) to this file extension, and therefore - to work with associated files - my app is importing this UTI and both extensions are listing „public.jpeg-2000“ in their info.plist as QLSupportedContentTypes. This works to some extent in simulators and when debugging from Xcode on a device: Files with the file extension „.JPX“ are listed with thumbnails provided by my extension, although the preview seems to invoke the system-provided viewer and fails. Not perfect, but good enough as my app requires an icon preview (aka thumbnail) in its UIDocumentBrowserViewController. But when I try to submit my app incl. extensions to the Apple App Store / TestFlight asset validation is reporting an error: „Asset validation failed. Invalid Info.plist value. The value for the key ‚QLSupportedContentTypes‘ in bundle … is invalid. [public.jpeg-2000] are system-supported types.“ How to assign QuickLook / Thumbnail extensions to 3rd party files types whose extension is conflicting with a system-supported UTI? I just spent one of my TSIs for this question - as my Apple developer membership is renewed shortly - but maybe this community as some smart tip to share... Appreciate any help, Mattes
Posted
by MyMattes.
Last updated
.
Post not yet marked as solved
0 Replies
226 Views
Hello, I am trying to write a simple QuickLook generator, which takes a file, runs an external binary to produce the data, and then creates and shows an image in a preview. The input files are uncommon data formats, and the binary in this case converts these to PNG. I have tried multiple methods and followed many discussions on these forums and StackOverflow, but unfortunately I am yet to get it working. That said, the program I have builds and runs using the qlmanage tool, however when running in Finder or on the server qlmanage -x the program fails. As I understand, it when using QuickLook in Finder it calls the QuickLook daemon quicklookd which is also called when using the qlmanage -x CLI command, but please correct me if I am wrong about this. The basic idea for all generator functions is: create NSTask or Process and run the third-party binary, using the requested file path as input run the task, pipe output, and read output convert the piped output to NSImage show image Attempt 1 (old-style qlgenerator plugin in Obj-C): Initially I tried adding the binary as an asset to the QuickLook Preview target and the generator would work as mentioned using qlmanage, however it would not work using qlmanage -x or from Finder. Here is the preview function: OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview, CFURLRef url, CFStringRef contentTypeUTI, CFDictionaryRef options) { NSLog(@"QuickLook plugin started"); NSInteger width = 512; NSURL *fileURL = (__bridge NSURL *)url; NSString *escapedFilePath = [fileURL.path stringByReplacingOccurrencesOfString:@" " withString:@"\\ "]; NSLog(@"Original Path: %@", fileURL.path); NSLog(@"Escaped Path: %@", escapedFilePath); NSBundle *bundle = [NSBundle bundleWithIdentifier:@"com.pjharrison.qlgwyddion"]; NSURL *nsURLExecutable = [bundle URLForAuxiliaryExecutable:@"gwyddion-thumbnailer"]; if (nsURLExecutable) { // The resource was found, and nsURLData is not nil. // Proceed with using nsURLData. NSLog(@"Resource 'gwyddion-thumbnailer' found in the bundle."); } else { // The resource was not found. Handle the situation accordingly. NSLog(@"Resource 'gwyddion-thumbnailer' not found in the bundle."); } NSTask *task = [[NSTask alloc] init]; NSLog(@"Pathhhh %@", nsURLExecutable.path); [task setExecutableURL:nsURLExecutable]; [task setArguments:@[@"kde4", [@(width) stringValue], escapedFilePath]]; NSLog(@"Task set"); NSString *argumentString = [task.arguments componentsJoinedByString:@" "]; NSLog(argumentString); NSPipe *pipe = [NSPipe pipe]; NSFileHandle *file = pipe.fileHandleForReading; [task setStandardOutput:pipe]; NSLog(@"Pipe set"); [task launch]; NSLog(@"Task launched"); NSData *data = [file readDataToEndOfFile]; NSLog(@"Got data"); [task waitUntilExit]; NSLog(@"Task completed"); NSInteger taskStatusCode = [task terminationStatus]; NSLog(@"Task finished with status code %ld", taskStatusCode); NSString *dataLength = [NSString stringWithFormat:@"%lu", data.length]; NSLog(dataLength); CGDataProviderRef imageDataProvider = CGDataProviderCreateWithCFData((CFDataRef)data); CGImageRef cgImage = CGImageCreateWithPNGDataProvider(imageDataProvider, NULL, true, kCGRenderingIntentDefault); if (cgImage) { CGFloat height = CGImageGetHeight(cgImage); CGFloat width = CGImageGetWidth(cgImage); CGSize size = CGSizeMake(width, height); // Preview will be drawn in a vectorized context CGRect rect = CGRectMake(0, 0, width, height); CGContextRef cgContext = QLPreviewRequestCreateContext(preview, size, true, NULL); CGContextDrawImage(cgContext, rect, cgImage); NSLog(@"Image drawn"); QLPreviewRequestFlushContext(preview, cgContext); NSLog(@"Flushed"); // release resources if (cgContext) { CFRelease(cgContext); NSLog(@"Context released"); } CGImageRelease(cgImage); NSLog(@"Image released"); } else { NSLog(@"cgImage is NULL"); } return noErr; } Inspection console logs would give various Operation not permitted errors when run from the quicklookd server. I suspect that possibly this is due to App Sandboxing issues. Attempt 2 After coming across various articles online by @eskimo and others, including the official docs and various other posts, I have tried to sign the binary executable as described in the documentation and embed it in the project. Unfortunately after signing the app I have not been able to get the executable to run. When called from the QuickLook Preview function, the process returns with an error code. Perhaps the issue is here and the executable has not been signed properly? Attempt 3 I have also tried to create a Swift-based app and add a QuickLook Extension to the app (creating an app with a .appex) using a similar flow as tried in Attempt 1. Also no luck here so far. At this point I am stuck and would appreciate any help or pointers! Many thanks in advance.
Posted
by harripj.
Last updated
.
Post not yet marked as solved
0 Replies
208 Views
Hello, I am experiencing an issue with a piece of JavaScript code that I use for triggering Quick Look on iOS devices. This functionality was working fine until the recent non-beta updates of iOS 17. It still functions as expected on older iOS versions and some beta versions of iOS 17, but not on the latest update. Here's the original code snippet: anchor.setAttribute('rel', 'ar'); anchor.appendChild(document.createElement('img')); anchor.setAttribute("id", "charpstar"); return (usdzSrc) => { anchor.setAttribute('href', usdzSrc + "#allowsContentScaling=0"); anchor.click(); }; With this code, the Quick Look feature used to work directly without navigating to an intermediary page. However, after the update, it ceased functioning. The error I am getting is "Object needs new version of iOS" To troubleshoot, I modified the code as follows: anchor.href = `${realityFileUrl}#allowsContentScaling=0`; anchor.addEventListener('click', (event) => { event.preventDefault(); window.open(anchor.href, '_blank'); }); // Append the anchor element to the document body. document.body.appendChild(anchor); // Click the anchor element to open the .reality file. anchor.click(); This revised approach does open the file, but it first navigates to an intermediary page, which is not acceptable for our client's user experience. Could you provide guidance on how to resolve this issue? Specifically, I'm looking for a way to use Quick Look on iOS 17 (non-beta versions) without being redirected to an intermediary page. Any insights or updates regarding changes in iOS 17 that might affect this functionality would be greatly appreciated. Thank you for your assistance.
Posted
by xlkarthik.
Last updated
.
Post not yet marked as solved
0 Replies
280 Views
Hi, I'm developing quick look extensions of my app's custom files to display previews and thumbnails in the finder. When I developed and debugged these extensions, they were listed on the "added extensions" in the System Settings > Privacy and Security > Extensions. And They worked. But, they don't appear on the list when I made a package and install it on my mac or testing machine. And the quick look didn't work at all. Should I configure build settings or packaging options to make them register(?) or work?
Posted
by freetbet.
Last updated
.
Post not yet marked as solved
0 Replies
307 Views
I'm getting Thread 5: EXC_RESOURCE (RESOURCE_TYPE_MEMORY: high watermark memory limit exceeded) (limit=6 MB) My thumbnails do render (and they require more than 6mb to do so), so I wonder about the behavior here. Does the OS try to render thumbnails with a very low memory limit and then retry if that fails?
Posted
by Audulus.
Last updated
.
Post not yet marked as solved
1 Replies
318 Views
By Apple's documentation, QLThumbnailProvider is used to generate thumbnails for custom file types. However i am trying to use it to generate thumbnails for public.image file type and it is not working. So can we override the system supported thumbnailer using QLThumbnailProvider?
Posted Last updated
.
Post marked as solved
1 Replies
532 Views
I received a rejection for "Your app spawns processes that continue running after the user has quit the app." The process in question is the app's Thumbnail extension. When I remove all of my own code from the thumbnail extension, it still continues to run after I exit my app. This is the entirety of the extension's code, which now renders blank thumbnails: import QuickLookThumbnailing class ThumbnailProvider: QLThumbnailProvider { override init() { } override func provideThumbnail(for request: QLFileThumbnailRequest, _ handler: @escaping (QLThumbnailReply?, Error?) -> Void) { let reply = QLThumbnailReply(contextSize: request.maximumSize) { (context: CGContext) -> Bool in return true } handler(reply, nil) } } Presumably Thumbnail extensions continue to run so that Finder (among others) can generate thumbnails as necessary. AFAIK, I have no direct control over the extension's lifecycle. Is this just App Review's mistake? The "Next Steps" are clueless: "You can resolve this by leaving this option unchecked by default, providing the user the option to turn it on." The app uses its own thumbnail extension to render thumbnails for document templates, which may be an uncommon thing.
Posted
by Audulus.
Last updated
.
Post not yet marked as solved
2 Replies
656 Views
Question asked during the 6-6-23 UIKit Q&A Slack session of WWDC 2023 My iOS / iPadOS / Catalyst app has a thumbnail extension with a QLThumbnailProvider subclass that implements the provideThumbnail(for:_:) method providing the thumbnail for a document created in my app, by drawing the thumbnail image into the current context. That implementation successfully updates the thumbnail for the document, but sometimes the thumbnail's displayed image (in, for instance, the Files app or my app's own UIDocumentBrowserViewController on iPhone or iPad) is slow to update. (This update slowness seems especially to be a problem for documents stored in iCloud Drive, rather than in local storage.) (1) Am I correct in presuming that the displayed thumbnail images are cached somewhere, and the reason the displayed thumbnail images are slow to update is because either (a) the thumbnail cache is slow to update and/or (b) the system only periodically calls the provideThumbnail(for:_:) method? (2) If so, is there some way my app can either (a) force the thumbnail image cache to update more quickly and/or (b) force the provideThumbnail(for:_:) method to be called, so that the displayed thumbnail images for the created/modified documents are quicker to update?
Posted
by chmohler.
Last updated
.
Post not yet marked as solved
1 Replies
742 Views
Hello, I am trying to add thumbnails to a replicated file provider extensions but the fetchThumbnails method never gets called. After adding the NSFileProviderThumbnailing protocol and fetchThumbnails method to my class I can see the change in behaviour in Finder when I click on a non materialised item as it displayed an empty space instead of the generic file type icon when the protocol is not added. I noticed the mention of caching based on itemVersion but I would still expect the fetchThumbnails method to be called for all newly enumerated items when Finder is in thumbnail mode ? Thanks,
Posted
by Stef1205.
Last updated
.