質問

I'm trying to figure an easy way to create screenshots at 1200x800 from nearly one hundred HTML files using QuickLook. This line pretty much sums up with I'm doing:

CGImageRef imageRef = QLThumbnailImageCreate(NULL, (__bridge CFURLRef) [NSURL fileURLWithPath:layoutHtml isDirectory:NO], CGSizeMake(1280   , 800), (__bridge CFDictionaryRef) @{ (NSString*) kQLThumbnailOptionIconModeKey:@(NO)});

Unfortunately the create image does not contain any images used in the HTML file, I only get the question mark "image not found" placeholder. When I use QuickLook from the Finder, images get loaded.

Any ideas on how I could convince QLThumbnailImageCreate to include images?

Thanks, Ilja

役に立ちましたか?

解決

I don't think this is possible unless there is hidden Preview Property.

The Generating Enriched HTML also does not mention anything about loading external resources, only kQLPreviewPropertyAttachmentsKey which requires the HTML to use the cid:identifier URL scheme.

There is webkit2png which is a python script that does what you need. Searching for WebKit screenshot solution also brings up some Cocoa code snippets.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top