Google Script to replace image background color? - google-apps-script

Looking to automate the tedious clicking to change the backround of my PNG images from white to transparent.
The images reside in Google Drive, and as new images are submitted I have to make it transparent, each time, again. There's got to be a better way!

I don't see any way to use that website with code. That website has what it calls an API, but it looks like it's nothing more than a link. You could use something like AutoIt, to reproduce the keystrokes that you manually do.
AutoIt website
If there was an online picture editor that had an API that would receive HTTP Requests, Apps Script can send and receive HTTP Requests.
Google Documentation urlFetch
But the online picture editor would also need to read your files from your Google Account.
HTML does have a canvas tag, that you can manipulate pictures with, but Apps Script currently doesn't work with the canvas HTML tag the last I knew.
You can access your Google Drive with Apps Script, and get files, but then you'd need to either send the file out somewhere, or process it yourself, just like that online picture editor does. If Caja would allow the HTML Canvas tag to work with HTML Service, there might be a way to automate what you want.
I created a way to re-size pictures with the Canvas tag, but it wouldn't work with Apps Script HTML Service.

Related

whats the best route to add graphic assets to a google web app script? [duplicate]

I have a webpage that has an image that is stored in google drive, and using the google drive embed code results in this-
and I want to include this image in my website without the border and tools, making it look like this-
Adding the image file to my project is not an option, as I am using google apps script as web domain as I am not old enough to have a credit card to purchase REAL web domain, and I am broke and cannot simply rake leaves or shovel driveways because of COVID. so I cannot add the image file to my project, any advice?
Answer:
Instead of the embed code, use the view link.
Example:
<img src="https://drive.google.com/uc?export=view&id=FILE_ID_HERE">
This solution is a little bit ironic. The tool that stack overflow uses for images can be used for anything else, so I just had to right-click on the image in this question, click on 'copy image URL' then put it in my website and I got a working image!

Properly embed Google Apps Script URL into Google Site

In Google Sites, it is possible to embed a Google Apps Script which has been published as a Web App. You just click "embed" and paste the URL of the Web App. It is possible to use the mouse to resize the iframe. However, I could not set the iframe to be of full width. Is that possible? Also, is it possible to make the whole page scrollable (instead of the iframe) when the Web App has some larger height as well? (I actually don't want to use any other functionalities of Google Sites except that it "hosts" my Google Apps Script with a custom URL and that it gets rid of the standard header warning that this Web App is not by Google).
Sorry
Unfortunately, AFAIK, this is not possible within Google sites.
I have experimented with various custom iframe HTML and CSS to try and find a workaround, but due to the way the site is rendered, it will always wrap your custom code in its own HTML and CSS. Any solution along these lines seems like it will be unreliable.
If you would like to see this specific functionality you can always submit a feature request.
My best workaround so far
Start a new site.
Delete all the elements, including the title.
Then add in your webapp embed.
It let me resize it vertically as far down as I wanted, it seems like full width since it is the only element on the page, and it doesn't present me with the warning.

How to view Google drive HTML as pdf in google drive

I would like to share pdf in google drive but even with featurs of preventing downloading and printing still can download it image by image that's why i thought to use another way after some research I found pdf2htmlEX so after i convert my pdf to html I upload it in google drive but when i wanted to opended it's appear as html code not as pdf
any help to solve that issue and any idea to share pdf without be downloadble image by image
It sounds like you're trying to secure your PDF and keep people from downloading/screenshotting its contents. Unfortunately, even if you successfully convert the PDF to HTML, people will still be able to view and therefore download/screenshot the contents. It's hard to prevent piracy.
As for the issue regarding your HTML files displaying as HTML in Google Drive, Google Drive doesn't support this. Google Drive no longer renders HTML files as of August 31, 2015:
https://gsuiteupdates.googleblog.com/2015/08/deprecating-web-hosting-support-in.html
If you're looking for a way to secure your PDF, most people will tell you that the simple answer is: you can't. Tools exist that help prevent screen recording and screen printing, but they're expensive and not foolproof. Someone can also just take a picture of their screen. The reality is that if you want to share content with the world through a PDF, you have to accept that it might be shared or stolen.
If you just want some basic protection through Google Drive, Google offers some advice for preventing copying and downloading:
To prevent commenters and viewers from downloading, printing, or
copying your file:
Click Share or Share Add people.
In the bottom right, click Advanced.
Check the box next to "Disable options to download, print,
and copy for commenters and viewers."
Click Save changes.
Click Done.
Source

Google App Script: Run script from within another script?

I am working on a payroll web app for my company. I was wondering if there is anyway to run a script from within another script. Such as having a hyperlink or something similar that the user could go and see a different UI and everything. If this is not possible, does anyone knows how to submit a copy of a html form to an email? I been trying to do this but GAS removes the styles and the JavaScript code that fills the form before sending it. I just need at least an image of the form so the manager could print it out and sign it.
Thanks
Yes, you can link from one script to another using regular anchors.
It's not Apps Script stripping your emailed form of this stuff. Email clients, including Gmail, intentionally don't support complex HTML. If you want an image, try creating a Google Doc with the DocumentsApp, converting it to pdf with document.getAs("application/pdf") and then emailing that.

Can I use Google Drive's editor interface embed in a website?

I want to use google drive to store the files, but allow the users of my website to be able to edit them transparently, so that they don't have to go to google drive's website.
Is this possible with the current API? Thus far I have only seen how to create an app for them to install in google drive, or doing something like DrEdit (https://developers.google.com/drive/examples/), which parses the files to JSON and uses the ACE editor, which is definitely not what I want.
EDIT:
I believe it is not possible to do this with Google Drive, I've decided to go with Zoho Docs instead.
Yes it's possible. The biggest consideration is how much formatting you want to support. Eg. if it's plain text, it's very simple. If you want to support character or layout formatting, it becomes more complex.
I don't believe its possible to embed the editor (or even embed a preview!) using an iframe, because if you look at how the google docs page loads, it first redirects you to the login page, and that automatically logs you in if you are already logged in, and redirects you back to the docs editor.
This means that the iframe would have to at least pass through the login page, even if the user doesn't need to enter anything. However, google's login page has the x-frame-option header set to SAMEORIGIN (or deny?), and thus, the browser refuses to display it, and thus you can't actually get logged in!
The only way I've found to enable just preview embedding (not editing), is to publish the document first (via the File->publish to web menu item).