Google Sheets! Issue with Image() Function - google-sheets

Let me try to explain my issue.
I've an image in my Drive URL = "https://drive.google.com/open?id=0B7Qr0kRr6yOOLXB1OE5lUUxBRjQ"
I converted it to "https://drive.google.com/uc?export=download&id=0B7Qr0kRr6yOOLXB1OE5lUUxBRjQ"
Replaced "open?id" with "uc?export=download&id"
I've modified URL of step 2 above in Sheet1!A1
At Sheet1!A5 When I use =Image(A1,1) it doesn't works.
but when I use =Image("https://drive.google.com/uc?export=download&id=0B7Qr0kRr6yOOLXB1OE5lUUxBRjQ",2) it works. This shows up image.
Q: What's the reason that when i use direct URL with Image Function it works but when i give cell reference of containing URL it won't.
Please help to find the issue! Thanks in advance.

use =Image(&A1,1)
this means "&" puts the value of A1 in the image formula and displays the image.

Related

Unable import text using importxml and xpath inside div

i'm Using Google Sheets with IMPORTXML to scrape a download count information from a japanese website via XPath in google sheet. I want to save the number/text inside this red box
here's the link
https://www.photo-ac.com/main/detail/4465781?title=%E3%82%A2%E3%82%B2%E3%83%8F%E8%9D%B6%E3%81%A8%E3%83%92%E3%83%A3%E3%82%AF%E3%83%8B%E3%83%81%E3%82%BD%E3%82%A6
here's my function
=IMPORTXML("https://www.photo-ac.com/main/detail/4465781?title=アゲハ蝶とヒャクニチソウ", "/html/body/div[17]/div/div/div/div[2]/div[7]/div[1]/div[1]/div/div[3]/div[2]/div[1]//text()")
the function doesn't work? why?
thank you
When I tested your formula, I confirmed that an error of Could not fetch url: occurred. But, fortunately, when Google Apps Script is used, I confirmed that the URL can be requested using UrlFetchApp. So, in this answer, I would like to propose to use Google Apps Script. The sample script is as follows.
Sample script:
Please copy and paste the following script to the script editor of Google Spreadsheet, and save it, and put a formula of =SAMPLE("URL") to a cell. If the function name is not found, please reopen the Google Spreadsheet and test it again. This script is used as the custom function.
function SAMPLE(url) {
const value = UrlFetchApp.fetch(url).getContentText().match(/ダウンロード:.+/);
if (!value) throw new Error("Value was not retrieved.");
return value;
}
Result:
When above script is used, the following result is obtained.
Note:
This sample script is for the current HTML of the URL of https://www.photo-ac.com/main/detail/4465781?title=アゲハ蝶とヒャクニチソウ. And, when the structure of HTML of the URL is changed, above script might not be able to be used. Please be careful this.
References:
Custom Functions in Google Sheets
fetch(url)

Error retrieving image from URL or bad URL with webContentLink

My application is trying to insert a bunch of images to google drive sheet using google app script.
The script method is calling from a Rails app as following:
#app_script.run_script(script_id, request)
The script method is trying to fetch the image through the id and insert it to the sheet.
var srcfile = DriveApp.getFileById(object.image_file_id);
srcfile.setSharing(DriveApp.Access.ANYONE_WITH_LINK, DriveApp.Permission.VIEW);
var image = SpreadsheetApp.openById(object.spreadsheet_id).getSheetByName(object.sheet_name).insertImage(Drive.Files.get(srcfile.getId()).webContentLink, object.column, object.row);
The problem is coming intermittently with the response error from google script:
Exception: Error retrieving image from URL or bad URL: https://drive.google.com/uc?id=1yZULGInEcjQ_nA4j_Nmy6F2e3JcYnLFP&export=download
Note that I can download the image successful if I just copy the link and paste it to browser.
The image file and its parent folder are public share.
It seem hard to detect the problem when it does not always happen.
For those who concern about my script, it is here
Exception: Error retrieving image from URL or bad URL
This is a common error message when the image size is too big.
See here for more information.
You need to recuce the image size - either manually or programmatically - before inserting.
UPDATE
If the suggestion above does not solve your issue, implement the following workaround:
Instead of inserting the image by its webContentLink with the method insertImage(url, column, row) , use the method insertImage(blobSource, column, row):
var image = SpreadsheetApp.SpreadsheetApp.openById(object.spreadsheet_id).getSheetByName(object.sheet_name).insertImage(DriveApp.getFileById(srcfile.getId()).getBlob(), object.column, object.row);
This should solve the issue.

Get an image through image path Alamofire

I am developing a little project for school where I have to get some information from this db: https://api.themoviedb.org/3/movie/popular?api_key=a4571caf3b2611c1effc82a2c8323b15&language=en-US&page=1
I would like to get the image thats in ["poster_path"] and put it into a tableView.
For other images I did this: cell.imageView?.image = UIImage.init(named: llibre.img)
but for a path, it doesn't work. I have already connected the bd to the project.
path example: "poster_path":"/jjPJ4s3DWZZvI4vw8Xfi4Vqa1Q8.jpg"
I have tried to replace "name" for path, and other silly things that doesn't work.
cell.imageView?.image = UIImage.init(path: \/jjPJ4s3DWZZvI4vw8Xfi4Vqa1Q8.jpg)
Any help would be very useful. Sorry for my english, it's not my native language.
Thank you
Based on Tmdb Document
You can concatenation the return value from api with this value
http://image.tmdb.org/t/p/w185/
result example : http://image.tmdb.org/t/p/w185//xmgAsda5sPNpx5ghJibJ80S7Pfx.jpg
This is value w185 for image size

Long URL as a command line doesn't work whereas a smaller URL works

I am trying to extract image frames from a video. I am passing the video URL as a command line argument. I am using a long URL as below.
Extract.exe C:\Users\Public\Videos\Sample Videos\Wildlife.wmv
This doesn't work and it calls the help(), maybe because of argument count not being equal to 2. (The argument count shows 3).
When I put a short URL as below,
Extract.exe F:\Wildlife.wmv
It works fine.
What could be the problem with the long URL command line ? How can I overcome this hurdle ?
You have some guidance for me ? Well, I am glad to have it with many thanks !!!
Its because you have spaces in your path name
Extract.exe "C:\Users\Public\Videos\Sample Videos\Wildlife.wmv"
should work.

replace special characters in a alternate text of image

I am trying to generate alternate text for the images in my blog to make my work easily and i found a mistake in the execution of this script.
If the image name is "image_good_looking.jpg" the output will be "image_good_looking".
Good upto some extent. If the image name is"image good looking.jpg" before upload it changes to "image+good+looking.jpg". I tried filename.replace("+"," "),title.replace("+"," ") But in the output there is no change in title and alternate text of the image.
this script must be placed after section
var filename = $img.attr('src')
$img.attr('title', filename.substring((filename.lastIndexOf('/'))+1, filename.lastIndexOf('.')));
$img.attr('title',filename.replace(/\W/," "));
This will replace all non-alfanumeric characters with space.
Is this what are you looking for ?

Resources