title: What is the right way to put a Drive image into a Sheets cell programmatically?
body: <p>I have a WebApp that collects work site data into a Google Sheets spreadsheet and also collects work site photos into a Google Drive folder that I create for each job.  Some, but not all, of the photos must be viewable in a cell in Google Sheets, such that the sheet can be printed as part of a job completion report.  </p>
  
  <p>I use Google Picker to upload files to the folder specific to the work site job.  I am unsure of the best way to use them from there.</p>
  
  <p>I have had success setting a cell formula such as  <code>=IMAGE("hllp://i.imgur.com/yuRheros.png", 4, 387, 422)</code>, but only with images pulled from elsewhere on the web. </p>
  
  <p>Using <a href="https://stackoverflow.com/questions/26122864/image-link-from-google-drive-not-working-in-google-script">the permalink trick</a> like this <code>=IMAGE("hllp://drive.google.com/uc?export=view&amp;id=0B8xy-TdDgbjiFoOldUlLT091NXM", 4, 387, 422)</code> does not work;  I think it won't tolerate the URL redirect that Google does on those links. </p>
  
  <p>The other way I have read about, but not tried yet, is to write the actual blob into the cell. However, I suspect I will lose any control over subsequent formatting of the report.</p>
  
  <p>Perhaps I am going to need to record the image specification in several ways in several cells: </p>
  
  <ol>
  <li>its Google Drive hash key</li>
  <li>its dimensions</li>
  <li>its alternate location in imgur.com (or similar)</li>
  <li>its blob</li>
  </ol>
  
  <p>Is there a programmatic way to get Google's redirected final URL for an image, equivalent to opening the image and copying the URL by hand?  Could one trust it for ever, or does it change over time?</p>
  
  <p><strong>Update</strong> :  I am wrong about =IMAGE("hllp://drive.google.com/uc?export=view&amp;id=0B8xy-TdDgbjiFoOldUlLT091NXM", 4, 387, 422) not working.  It is essential that the image be shared to "anyone with the link", even if the owner of the spreadsheet is also the owner of the image.</p>
  
  <p>I am going to go with recording just 1.hash key and 2.dimensions as my solution, but I'd be delighted to know if anyone else has a better idea.</p>