Further question on "insert image in Google colab text cell" - google-colaboratory

I followed the question and answers to question on inserting images into Colab text cells. Similar to that poster, I wish to place images into text cells rather than bring them up using Python code cells.
The source of the images is intended to be files in a subfolder of the project containing the Jupyter notebook whose discussion I want to enrich with photos and drawings. It is important to keep the notebook and supporting files, including images and data, in a single encompassing folder. (I expect to work on dozens of such projects, each with its own assembly of files in separate project folders.)
In order to achieve this I mounted the Google drive containing the image files by running
from google.colab import drive
drive.mount('/content/drive')
I clicked on the file folder in the left sidebar and expanded directories until I could select the image file I want to use and obtain its path. Then I tried using either of the following in a text cell:
<img src="/content/drive/MyDrive/Colab Notebooks/Lab13 Mechanisms/Figures/PantographCloseUp.JPG" alt="Close up of a pantograph made with LEGO Technics and LEGO Mindstorms components">
![Close up of a pantograph made with LEGO Technics and LEGO Mindstorms components](/content/drive/MyDrive/Colab%20Notebooks/Lab13%20Mechanisms/Figures/PantographCloseUp.JPG)
Neither of these work: no image appears. Right clicking on the empty box containing a question mark and choosing inspect element and then the tab "sources", I clicked on the image resource and got "Failed to load resource: the server responded with a states of 403 ()." I understand this is some sort of authorization fault (???).
(The image is set to be shared with anyone with the link.)
What is going on? Why don't the image-in-text-cell methods work using the file paths on the mounted drive? (Ideally, too, I would like to use a relative path: Figures/PantographCloseUp.JPG)
Please note that the following does produce an image in a text cell but is not a terribly convenient way of keeping track of image sources:
<img src='https://drive.google.com/uc?id=1dYjA01xQqah0l2cSQYcd6U0UFrfH3LPK'/>
Also, I can run code to display the image using the desired file path but this is also not convenient because a user (a student) of the document would have to run all of these cells just to look at the pictures.
from IPython.display import Image
Image("/content/drive/MyDrive/Colab Notebooks/Lab13 Mechanisms/Figures/PantographCloseUp.JPG")

Related

Android camera, take picture(s) and save as multipage PDF, then upload to server via <input type="file" />

I have a webform with and want to open it on smartphone - than take pictures of some documents which need to be merged in one PDF, and on the end this file need to be uploaded to server.
My solution is to use Google Drive to upload PDF (scan) to GDrive and then somehow download this file from gdrive to server via some sort of widget (any links appreciate) installed on website.
Maybe someone have a better idea?
I know its late but my answer might help others. I also face the same challenge and implemented a custom solution based on Javascript and Since you are using web form so this solution will perfectly fits on your need.
You have to use JSPdf javascript library, JSPdf provide you pdf object in your browser and you can upload it download it and there are many other thing to play with.
First you have to initialize JSPdf object as per your requirement. I am creating PDF with page size width:500px and height 500px.
pdf = new jsPDF("l", "pt", [500,500]);
Simply when you will take picture from camera you will have each picture in form of base64, that base64 format you have to insert in JSPdf object
pdf.addImage(imgData, 'JPEG', 0, 0);
you can repeat the above code to add pictures from camera as much as you want, at the back-end these images are compiling and creating pdf document where each page have each images in sequence.
Once you are done, you can get PDF object in form of base64 object using below code that you can upload to any server.
pdf.output('datauristring')
above is only pdf part, you can find complete working example including camera part here Javascript Component to Scan Document

How to save all images from website using webscraping or macro

In my job of e-commerce i have to save images from MFG. sites to upload them to my client webpage, sometimes when product came like apple i6 there are hundreds of images in product description
so i want to save all images from mfg url with one click
For example:
URL- http://www.gsmarena.com/samsung_galaxy_a9_%282016%29-pictures-7641.php
it have 7 images, so i wanna get all images downloaded in single click
image links:
http://cdn.gsmarena.com/imgroot/reviews/15/apple-iphone-6s/-347x151/thumb.jpg
http://cdn2.gsmarena.com/vv/bigpic/samsung-galaxy-a9-2016-.jpg
http://cdn2.gsmarena.com/vv/bigpic/samsung-galaxy-a9-2016-.jpg
http://cdn2.gsmarena.com/vv/pics/samsung/samsung-galaxy-a9-2016-6.jpg
http://cdn2.gsmarena.com/vv/pics/samsung/samsung-galaxy-a9-2016-7.jpg
http://cdn2.gsmarena.com/vv/pics/samsung/samsung-galaxy-a9-2016-5.jpg
http://cdn2.gsmarena.com/vv/bigpic/samsung-galaxy-a8-.jpg
Maybe this way?
Image Picker Plugin for Firefox
Seems it does the same job without any installation (but plugin installation).
Not sure if it is, what you are looking for. But I tryed it and found an easy option for you.
Use the tool: jdownloader2
Copy the link of your desired URL and paste it into the link collector. It gathers automatically all the pictures on that page and downloads it for you. All images with a single click...

Screen Scraping with HTTP Headers Issue - I Think

I've been trying to figure this one out for about a week now and just
can't come up with a good solution. So, I figured I would see if anyone could help me out. Here's one of the links that I'm trying to scrape:
http://content.lib.washington.edu/cdm4/item_viewer.php?CISOROOT=/alaskawcanada&CISOPTR=491&CISOBOX=1&REC=4
I right-clicked to copy image location.
This is the link that is copied:
(Can't paste this as a link because I'm new)
http:// content (dot) lib (dot) washington (dot) edu/cgi-bin/getimage.exe?CISOROOT=/alaskawcanada&CISOPTR=491&DMSCALE=100.00000&DMWIDTH=802&DMHEIGHT=657.890625&DMX=0&DMY=0&DMTEXT=%20NA3050%20%09AWC0644%20AWC0388%20AWC0074%20AWC0575&REC=4&DMTHUMB=0&DMROTATE=0
There is no clear image URL being displayed. Obviously that's
because the image is hidden behind some type of script. Through trial and
error I found that I can put ".jpg" after the "CISOPTR=491" and then the link becomes an Image URL. The problem is that this is not the high-resolution version of the image. To get to the
high-resolution version I have to change the URL even more. I found a lot of articles #Stackoverflow.com to mention trying to build a script using curl and PHP, I have even tried a few of them with no luck. "491" is the image number and I can change that number to find other images in the same directory. So, scraping a sequence of numbers should be pretty easy. But I'm still a noob at scraping and this one is kicking my butt. Here's what I've tried.
Get remote image using cURL then resample
also tried this.
http://psung.blogspot.com/2008/06/using-wget-or-curl-to-download-web.html
I also have Outwit Hub, and Site Sucker, but they don't recognize the URL as an image file and fo they just pass right ove it. I used SiteSucker overnight and it download 40,000 files and only 60 were jpegs, none of which were the ones I wanted.
The other thing I keep running into, is the files I have been able to download manually, the filename is always either getfile.exe or showfile.exe and then if I manually add ".jpg" as the extension I can view the image locally.
How can I reached the original high-res image file, and automate the download process so that I can scrape a couple hundred of these images?
I right-clicked to copy image location. This is the link that is
copied:
You noticed the title has ".exe" in there. Look at the stuff in the query string:
DMSCALE=100.00000
DMWIDTH=802
DMHEIGHT=657.890625
DMX=0
DMY=0
DMTEXT=%20NA3050%20%09AWC0644%20AWC0388%20AWC0074%20AWC0575
REC=4
DMTHUMB=0
DMROTATE=0
Strongly implies the original source of this image is in a database or something and it is being passed thru a server-side filter (not sure if that is what you meant by "some kind of script"). Ie, this is dynamically generated content, not static, and the same caveats apply as would to dynamic text content: you have to figure out what instructions to provide the server to get it to cough up what you want. Which you pretty much have in front of you...if SiteSucker or whatever won't deal with it properly, scrape the address yourself using an HTML parser.

VBA Export embedded video from Powerpoint presentation

I'm trying to convert an entire presentation to HTML, extracting all the embedded content etc along the way. I've got text, audio, narrations etc all working fine but am having trouble finding out how to export video content.
Im looping through all slides in the presentation, then all shapes on the slide, looking for shapes of type msoMedia. If I find one, then I check it's MediaType. If it's ppMediaTypeMovie, then I can find the source file of an externally linked video file using Shape.LinkFormat.SourceFullName, but I can't for the life of me find out how to access EMBEDDED content.
If I find a shape with a MediaType of ppMediaTypeSound then I can use Shape.SoundFormat.Export to export the audio. Does anybody know of an equivalent for VIDEO shapes? (There's no Shape.VideoFormat) I've spent days looking through every possible data member I can but to no avail.
It appears Microsoft extract the contents of the media file to a temporary folder anyway, and embedded videos still provide a LinkFormat.SourceFullName to the extracted video:
?oshape.LinkFormat.SourceFullName
C:\Users\Alex\AppData\Local\Microsoft\Windows\Temporary Internet Files\Content.MSO\F26FF1D0.m4v
All that I need to do is fire this file through ffmpeg and I've got my video, in the format I want!
Thanks for your help :)
Note: You may find that the .Export method doesn't work for embedded sounds either in recent PPT versions.
Alex's suggestion is what I'd look into first; otherwise you can unzip the PPTX/PPSX/etc and find the videos in the media folder. Or you might try saving as an XML presentation; you might be able to parse the video out of that.

How to load an image with unique names from a private folder?

I am working on an app for iPad where I want to have lets say 100 jpg's in a folder.
They could be named like 01.jpg, 02.jpg etc.
In my app I like to browse those images and when clicking on one of them I need the name of the image to be able to send some data over the network (the data part works fine).
I tried to use UIImagePicker but I found out there are no name connected to the actual image.
Then I made another approach where I have a number of pages where I have buttons and here I load in the images which works fine as long the are a part of the recourse of the project...
But here comes the real problem.
The user of the app should be able to change those images over time without recompiling the app.
So I do look for a way to have a folder where the user can place/replace images with the names 01.jpg etc and the app to use those updated images.
Ideas are very welcome.
Wiljan
I am not sure that I understand what you mean, but You can save images in your application documents folder. You can find more details at:
http://developer.apple.com/library/ios/#documentation/iphone/conceptual/iphoneosprogrammingguide/StandardBehaviors/StandardBehaviors.html#//apple_ref/doc/uid/TP40007072-CH4-SW6
You can also use NSFileManager to copy files.
what I suggest to do is :
put default images on project resources.
At first start, copy files to documents folder.
always use images from documents folder.