tanaikech / imgapp Goto Github PK
View Code? Open in Web Editor NEWThis is a library of image tools for Google Apps Script.
License: MIT License
This is a library of image tools for Google Apps Script.
License: MIT License
Thanks for this library.
I was able to resize 2 images and then merge them into one.
However, I need to get the URL of the resulting image to save it on a CMS.
How do I get it?
Is it possible to find the image resolution measured in pixels per inch (PPI)
Similar to: https://github.com/MikeKovarik/exifr#installation
Many thanks
This is particularly useful for vertical images. If this would be possible I would be very grateful.
Seems to not work for images on a team drive.
If I move the image to my drive and run your resize, it works fine. But errors out on the file ID on a team drive.
I want to use your ImgApp in a script but I dont have the files in google drive yet. I will however be grabbing from Twitter profile images and wanting to resize them from 48x48 to 32x32. I can grab the blob from the URL they give me to the profile image, so it would be nice not to have to save a copy to Google Drive in the meantime as I process it and then commit the blob to a github repository within the same script.
I looked at the code and it appears the top of the coffee script is what ddrives the user accessible functionality. If we added the following I believe we can achieve this:
/**
* <h3>usage</h3>
* var res = ImgApp.doResizeOnBlob(blob, width);<br>
*<br>
* @param {string} blob The blob of the image to resize
* @param {integer} width Resized width you want
* @return {Object} JSON object {blob: [blob], originalwidth: ###, originalheight: ###, resizedwidth: ###, resizedheight: ###}
*/
function doResizeOnBlob(blob, width) {
return new ImgApp().DoResizeOnBlob(blob, width)
}
Then add a DoResizeOnBlob
method that will contain a call to GetResizedSize
and a similar set of returns as DoResize
would return.
I am not that familiar with Coffee scripts, so I figured I would put in a request instead of trying to develop something myself without much understanding of how it all works or how to properly test.
This functionality would be really really helpful and seems like an easy thing to implement. Alternatively, you could have the end of DoResize
return what the internal function for this new functionality would return, so the code isnt being duplicated, just broken out so it had more options for users. But again, not entirely sure how it all works, so I shall let you figure out if you wish to attempt that path as well.
I started using ImgApp successfully, but then tried changing my sample image.
Initially I was using a 1200x1200 pixel simple png image that was only 16KB in size.
When I changed it to a file that was larger in terms of file size, I started to get an error:
Exception: Request failed for https://lh3.googleusercontent.com returned code 400. Truncated server response: <!DOCTYPE html>
<html lang=en>
<meta charset=utf-8>
<meta name=viewport content="initial-scale=1, minimum-scale=1, width=device-width">
<titl... (use muteHttpExceptions option to examine full response)
I haven't found a way around that yet. It seems like the limit is something between 70 and 75 KB.
I am working on a tool that works with HtmlSerivce in GAS to shrink images.
The doRisize(), which used to work, does not run and gives the following error.
stack:Error: '*****************' is not compatible file. Error message is {}
at ImgApp.DoResize (code:308:15)
at Object.doResize (code:35:23)
On the other hand, in the test environment (different script ID) with the exact same source,
doResize() runs and shrinks the image.
Note that getSize() is still available in the same environment.
Do you have any idea what the cause might be?
Hello.
I have some TIFF files over 200 mb.
I wanted to get data about the width and height of an images. But Google does not process files over 200 MB. The get.Width() and get.Height() request returns 0. For TIFF files less than 200 MB, I can get their sizes.
Fragment of code:
let fileId = file.getId();
let dims = Drive.Files.get(fileId, {supportsAllDrives: true}).imageMediaMetadata;
let width = dims.width;
let height = dims.height;`
I tried using your doResize () function but got this answer: "Is not compatible file"
Is it possible to solve this problem using your application? Or maybe there are some other ideas?
Would it be possible to make it log the error that it's catching on https://github.com/tanaikech/ImgApp/blob/master/src/ImgApp.coffee#L113-L114
can you help me to make function to get screenshot every page 1 in a document in a folder?
こんちにわ。ImgAppを使わせていただき、GASで開発を行っています。
doResizeを行った時に、以下のようなエラーが出ています。
スクリプト内容
function test_resize(){
var fileId ='***************';
let res = ImgApp.doResize(fileId, 500);
}
エラーメッセージ
Error: '***************' is not compatible file. Error message is {}
ImgApp.DoResize @ コード.gs:303
doResize @ コード.gs:35
getSizeは問題なく実行でき、対象のファイル形式はJPG形式となっております。
{identification=JPG, filesize=4040889.0, height=3024.0, width=4032.0}
appscript.jsonの内容を
{
"timeZone": "Asia/Tokyo",
"exceptionLogging": "STACKDRIVER",
"runtimeVersion": "V8",
"dependencies": {
"libraries": [
{
"userSymbol": "ImgApp",
"libraryId": "1T03nYHRho6XMWYcaumClcWr6ble65mAT8OLJqRFJ5lukPVogAN2NDl-y",
"version": "10"
}
]
},
"webapp": {
"executeAs": "USER_DEPLOYING",
"access": "ANYONE_ANONYMOUS"
},
"oauthScopes": [
"https://www.googleapis.com/auth/spreadsheets",
"https://www.googleapis.com/auth/drive.readonly",
"https://www.googleapis.com/auth/drive",
"https://www.googleapis.com/auth/script.container.ui"
]
}
こちらに書き換えると実行ができます。
{
"timeZone": "Asia/Tokyo",
"exceptionLogging": "STACKDRIVER",
"runtimeVersion": "V8",
"dependencies": {
"libraries": [
{
"userSymbol": "ImgApp",
"libraryId": "1T03nYHRho6XMWYcaumClcWr6ble65mAT8OLJqRFJ5lukPVogAN2NDl-y",
"version": "10"
}
]
}
}
ただし、他の新規GASスクリプトファイルを作成し、oauthScopesがない状態でもエラーがでます。
複合的な条件だとは思いますが、oauthScopesは必要でして、原因をご調査いただけないでしょうか。
何卒、よろしくお願いいたします。
According to this: https://developers.google.com/apps-script/reference/drive/file#getAs(String)
It appears we can get the blob as a different type. I am wondering if we can make doResize optionally always return the image as a passed in mime-type?
I think it can be used when we first get the blob to convert it or alternatively, to make use of this functionality right before returning the new blob when performing the resize.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.