Comments (5)
Thank you for your comment. In your comment, you want to modify the height but you don't want to modify the width. Is my understanding correct?
from imgapp.
Thanks for your quick reply. Excuse me if I was unclear. With your function, doResize, I can input the width for an image to scale it, but keep the same aspect ratio. However, I found out that for vertical images, width (in your function) means the 'longest' side, so the vertical side. This was a bit confusing. But the real problem for me is that I have an maximum length for the horizontal side (of an vertical image). Which with your function would be height. So when I set the width of a 4:3 vertical image it's height will be longer then if I set an 16:9 vertical image with the same width. Therefore I'd like to set It's height to a specific value and scale it accordingly. This way the image fits my boundaries. I'm not very experienced with google script so I can't figure this out myself. Hopefully you'll be able to help. If you still have doubts about my question, I could make some screenshots of my problem with annotations.
from imgapp.
Thank you for replying. I'm really sorry for my poor English skill. I couldn't understand about "vertical images". And unfortunately, I cannot see the vision of your issue. But I can show you the method of resize of this library. You can see the detail information at here. If this is not useful for your situation, I'm sorry.
from imgapp.
I figured it out with basic google script functions, if other people find this, this may be of use:
//[...]
//create image with width of 500 and correct aspect ratio
//if it is vertical image this also works (width is always the width)
var newWidth = 500;
//oImg contains the appended image
oImg = oImg.getParent().asParagraph().appendInlineImage(blob);
// Calculate (aspect) ratio
var orgWidth = oImg.getWidth();
var orgHeight = oImg.getHeight();
var ratio = orgHeight/orgWidth;
//Calculate new height for width of 500 and same ratio
var newHeight = newWidth*ratio;
//Set new height and width to image
oImg.setWidth(newWidth).setHeight(newHeight);
from imgapp.
I'm glad your issue was solved.
from imgapp.
Related Issues (13)
- Images on Team Drives HOT 4
- Feature Request: Resolution of image (ppi)
- doRisize() stopped working. HOT 4
- Error: '***************' is not compatible file. Error message is {} HOT 3
- Unable to look up library
- Add option to send in blob instead of FileId? HOT 2
- Feature Request: Resize and convert HOT 10
- Log Error HOT 2
- get screenshot page 1
- I merged 2 images. How I get the URL of the resulting image in Drive? HOT 1
- Issue with images over a certain filesize? HOT 1
- "Is not compatible file"
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from imgapp.