Copy and paste figures into Google Docs
Hi there,
In our daily experiment routine, we use Google Docs and Slides to quickly share results. The Export Graphics feature in Igor Pro allows one to directly copy and paste figures, i.e., Ctrl+C on a graph window, and Ctrl+V in Google Docs through a browser (Chrome). But the behavior is not quite consistent across OS platforms and Igor Pro versions.
In Windows, I am able to do this with Igor Pro 6 using bitmap as the graph format. But in Igor Pro 7 and 8, neither bitmap or other formats work any more. At the same time, Ctrl+V in PowerPoints still works for bitmap.
In OSX, all work fine. I can do this in Chrome or PowerPoints with most graph formats.
Basically the only scenario that doesn't work is copying from Igor Pro 7 or 8 to Google Docs in Windows, which, unfortunately, is our most frequently used case. (Currently, we just use the snipping tool in Windows to take screenshots.) I guess something about the graph format must have changed since ver 7. It would be nice if this can be made compatible again.
Thanks!
Hmmm... I can't paste in Google Docs (I'm using Chrome on Windows) but I can upload a graphic file into a picture in a Google Doc.
A Windows bitmap is really no longer a good choice. Igor 7 and later won't make a Windows bitmap in general unless you change the Graphics Technology to GDI (the old-style Windows graphics). You can change it by selecting Misc->Miscellaneous, select the Miscellaneous category, and choose GDI from the Graphic Technology menu.
But please don't do that- GDI and bitmaps don't support transparency, which is finally supported in Igor 7.
Instead, if bitmaps used to be acceptable, you should now be using PNG. It is another bitmap format, but much more efficient than a Windows bitmap, and it supports transparency. You can make PNG's on both Windows and Macintosh, so they are cross-platform, too.
November 5, 2018 at 02:47 pm - Permalink
I should have said that you can read about graphics technology by executing this Igor command: DisplayHelpTopic "Graphics Technology"
November 5, 2018 at 02:49 pm - Permalink
Empirically, Igor 6.37 puts the following formats on the clipboard when you export as bitmap: CF_BITMAP, CF_DIB, CF_DIBV5, and special(*)
Igor 8.02 puts the following on the clipboard: CF_DIB, image/x-ms-bmp, special(*)
(*) special is an Igor specific clipboard format that contains data about the picture copied to the clipboard. This data isn't relevant here.
I assume that Google docs isn't able to paste when you copied using Igor 8 because it's looking for either CF_BITMAP or CF_DIBV5.
However, based on my understanding of https://docs.microsoft.com/en-us/windows/desktop/dataxchg/clipboard-for…, the OS should be able to fulfill a request of CF_BITMAP, CF_DIB, or CF_DIBV5 data if the clipboard has CF_DIB data. So I don't have an explanation for why this is happening.
Dealing with clipboard formats on Windows is delicate, as in my experience making a change in one place for one specific reason is likely to break pasting into some other application.
November 5, 2018 at 03:04 pm - Permalink
Heh. Adam was kind enough not to point out that much of my answer was, um, bull. We CAN copy a Windows bitmap. But be aware that if you use transparent colors in your graph, you will be disappointed with the bitmap that results.
Adam, of course, had the real answer for you.
November 5, 2018 at 03:28 pm - Permalink
Thanks, John and Adam, for the information. Image quality is not a concern for us when using google docs. It is mostly for its convenience of sharing.
Perhaps this is a Chrome issue. Interestingly, if I copy from igor 7 and first paste the image in powerpoint, then copy from powerpoint, now I can paste it in google docs. I guess powerpoint loads a converted image data into clipboard, which chrome can recognize.
November 5, 2018 at 04:54 pm - Permalink
In reply to Thanks, John and Adam, for… by nanowave
Yeah, going through PowerPoint works because PPT is putting an entirely new copy of the image on the clipboard, and likely in whatever format is required for Docs to paste. When I get a chance, I'll see if I can figure why we're not putting DIBV5 data on the clipboard--that's probably the reason the paste isn't working currently.
If you want to bump the priority of this up a bit, send us a message via support@wavemetrics.com, and include your system information (Help->System Information or Help->Contact Support). Knowing who you are and whether you have a valid license helps us to prioritize time sinks like this kind of problem :)
November 5, 2018 at 07:22 pm - Permalink
In reply to Empirically, Igor 6.37 puts… by aclight
Wanted to follow up on this as I came across a webpage to test clipboard.
http://madebyevan.com/clipboard-test/
When an image can be successfully pasted into Chrome, the log would show both 1 file and 1 item.
But when I tried to paste an image copied from Igor as BMP, it will only show 0 file and 1 item.
Not sure if this information may help with the debug. Also this stackoverflow thread seems to be somewhat relevant.
https://stackoverflow.com/questions/6333814/how-does-the-paste-image-fr…
Btw, when you mentioned "Igor 8.02 puts the following on the clipboard: CF_DIB, imate/x-ms-bmp, special(*)", I assume "imate" is a typo, right?
December 13, 2018 at 12:03 am - Permalink
In reply to Wanted to follow up on this… by nanowave
This is (at least partly) a bug in Chrome.
You can verify this by using Edge on Windows 10 at the clipboard test site you found. If you copy an image from Igor 8.02 as Bitmap and paste into the test site, everything works as expected. I haven't tested Firefox so I don't know if it works correctly or not. I haven't tried using Gmail or Google Docs from Edge but I assume pasting would work correctly.
To see what's going on, I recommend you use a simpler test site: http://jsfiddle.net/bt7BU/225/. When you paste into the text area, the javascript function on the lower left executes. If you're using Chrome with a bitmap copied using Igor 8, the items variable will contain one item. That item's type is "image/png", so execution gets to line 9. However items[i].getAsFile() returns null instead of the file's data. If you copy from Igor 6, or use Edge, then getAsFile() returns valid data, and execution continues.
Earlier in the thread, I mentioned the clipboard formats that Igor 6 and 8 make available, and in neither case is "image/png" placed on the clipboard when you are copying using Bitmap format in Igor. What happens is that the browser has code to translate certain native clipboard formats into png for use by javascript applications. You can see some of the code Chrome uses for this in ClipboardWin::ReadImage (line 601) at https://chromium.googlesource.com/chromium/src/+/master/ui/base/clipboa…. It calls the Windows API (GetClipboardData(CF_DIB)) and then translates that into a SkBitmap. Presumably, somewhere down the line, the browser converts the SkBitmap into a png file and makes that available to javascript code. I believe that one of these conversions (Bitmap->SkBitmap or SkBitmap->png) is failing in Chrome. The reason it is failing is that the bitmap data that Igor 8 places on the clipboard uses a negative value for the height, which indicates that the data is stored top down (vs. bottom up if the height is positive). This is perfectly valid (see https://docs.microsoft.com/en-us/previous-versions//dd183376(v=vs.85)) but apparently is somewhat uncommon and Chrome doesn't correctly account for this possibility. I looked through the Chromium bug tracker and I don't see a report about this.
When Igor 6 copies Bitmap data to the clipboard, it uses a positive value for height. I'm not sure why the change was made, and I'm not sure whether we could safely undo the change.
I meant image, not imate. I've fixed the earlier post.
December 13, 2018 at 01:19 pm - Permalink
Thanks for the information. It does sound like the clipboard on windows is tricky to deal with.
Since you mentioned it works in Edge, out of curiosity, I tried a couple of other programs that allow pasting images, and here is what I found.
Working:
Microsoft Office
Paint
GIMP
Not working:
Adobe Illustrator CC 2015
Adobe Photoshop CC 2015
Slack
In Illustrator, it would only paste a blank object. When I changed the figure size in Igor, the size of the pasted object changed accordingly.
In Photoshop, an error message actually poped up and said "Could not import the clipboard because an unexpected end-of-file was encountered."
Not sure if the cause is the same as that in Chrome as they may handle the clipboard differently, but I thought I would report this behavior just in case it might ring a bell.
Images copied from Igor6 worked in all of these.
December 13, 2018 at 11:02 pm - Permalink