title: Why does QLPreviewRequestSetDataRepresentation on Mavericks return error " CGImageCreate: invalid image size: 0 x 0" for png
body: <p>My quick look generator used to work properly but is now broken.<br>
  Is it a bug or am I doing something wrong?  </p>
  
  <p>Here’s my code:</p>
  
  <pre>
  OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview, 
                                 CFURLRef url, CFStringRef contentTypeUTI, 
                                 CFDictionaryRef options) {
  
      NSDictionary * myDoc = [NSDictionary dictionaryWithContentsOfURL:(NSURL *)url];
  
          if (myDoc) {
  
              NSData * pngData = [myDoc valueForKey:@"pngPreview"];
  
              if (pngData) {
  
                  QLPreviewRequestSetDataRepresentation(preview,(__bridge CFDataRef)pngData,
                                                        kUTTypeImage,NULL);
              }
          }
  }
  </pre>
  
  <p>My doc is a normal plist with a png preview stored as data in it.<br>
  I checked that pngPreview does contain png data, I created the image and its size was 350×350.</p>
  
  <p>However, I’m constantly getting these errors:  </p>
  
  <pre>qlmanage[702] : CGImageCreate: invalid image size: 0 x 0.<br />
  qlmanage[702:303] *** CFMessagePort: bootstrap_register(): failed 1100 (0x44c) 'Permission denied', port = 0x9e27, name = 'com.apple.tsm.portname'
  See /usr/include/servers/bootstrap_defs.h for the error codes.<br />
  qlmanage[702:303] *** CFMessagePort: bootstrap_register(): failed 1100 (0x44c) 'Permission denied', port = 0x3f2b, name = 'com.apple.CFPasteboardClient'
  See /usr/include/servers/bootstrap_defs.h for the error codes.<br />
      qlmanage[702:303] Failed to allocate communication port for com.apple.CFPasteboardClient; this is likely due to sandbox restrictions</pre>
  
  <p>My app is not sandboxed so I don’t think the last 3 errors are important.</p>
  
  <p>I used to use kUTTypePNG but have tried kUTTypeImage to no avail (the docs for QLPreviewRequestSetDataRepresentation says currently supported UTIs are kUTTypeImage, kUTTypePDF, kUTTypeHTML, kUTTypeXML, kUTTypePlainText, kUTTypeRTF, kUTTypeMovie, and kUTTypeAudio).</p>
  
  <p>Other points to consider:
  The docs state:
  "The binary of a Quick Look generator must be universal and must be 32-bit only." <a href="https://developer.apple.com/library/mac/documentation/userexperience/conceptual/quicklook_programming_guide/Articles/QLArchitecture.html" rel="noreferrer">This page</a>
  But <a href="https://developer.apple.com/library/mac/documentation/userexperience/conceptual/quicklook_programming_guide/Articles/QLProjectConfig.html" rel="noreferrer">this page</a> states:
   "For OS X v10.6 and later, you must build Quick Look generators for both 32- and 64-bit." Which is rather unclear...<br>
  How do I set my target?</p>