Skip to content

Instantly share code, notes, and snippets.

Created December 18, 2015 18:02
What would you like to do?
google apps script image to text ocr
function doGet(request) {
if (request.parameters.url != undefined && request.parameters.url != "") {
var imageBlob = UrlFetchApp.fetch(request.parameters.url).getBlob();
var resource = {
title: imageBlob.getName(),
mimeType: imageBlob.getContentType()
var options = {
ocr: true
var docFile = Drive.Files.insert(resource, imageBlob, options);
var doc = DocumentApp.openById(;
var text = doc.getBody().getText().replace("\n", "");
return ContentService.createTextOutput(text);
else {
return ContentService.createTextOutput("request error");
Copy link

glebret commented Sep 21, 2018

The 'Drive' Classe in Drive.Files doesn't exsit anymore (replace by DriveApp Class).

Copy link

Copy link

how to use this script?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment