Scale layer to fit project?

Wondering how to accomplish a certain animation task? Ask here.

Moderators: Fahim, Distinct Sun, Víctor Paredes, erey, Belgarath, slowtiger

Scale layer to fit project?

Postby litote » Mon Feb 18, 2019 5:32 pm

If I want to import an image that is larger than the project dimensions, is there a way to automatically scale it to fit,or do you have to do it manually with the Transform Layer tool??
litote
 
Posts: 30
Joined: Mon Feb 18, 2019 12:16 pm

Re: Scale layer to fit project?

Postby Greenlaw » Mon Feb 18, 2019 6:02 pm

Moho uses the project size as a point of reference so Moho will import background art relative to the project size. So, if the BG art's pixel size is larger than the project size, Moho will naturally import it that way.

Knowing this, here's what you need to do:

If this is a new project, create the project at the exact size of your background, import the image, and then resize the project to the size you actually want. The image will be sized proportionately along with the project to the target size. Note that Moho preserves the original pixel size in the re-scale...in other words, this is a non-destructive scaling, so if the image started out much larger than the final project size, you will be able to push into the image a bit before the quality degrades.

If you have a bunch of BG images the same size, set the project size to match and bring them all in at once. After you re-sizing the project size in Project Settings, the images will all size proportionately together.

If you're importing the BG art after you've already set up your project, you can temporarily scale the project up to match the BG's pixel dimensions then size it back after import. As in the above, the BG's proportions should be preserved to the new project scale automatically.

The above assumes the bg art's proportions are the same as the projects. If the proportions of the BG is not the same as the project's, then you need to match only one side of the image in the project scaling. For example, if the image is extra wide for panning, like a scrolling bg, then you should match only the vertical height when you import the art.

Hope this helps.
User avatar
Greenlaw
 
Posts: 4210
Joined: Mon Jun 19, 2006 5:45 pm
Location: Los Angeles

Re: Scale layer to fit project?

Postby synthsin75 » Tue Feb 19, 2019 12:23 am

Here's a menu script I just wrote to make an image layer either fit or fill the project dimensions: https://sites.google.com/site/synthsin/ ... ects=0&d=1

Fit will fit the longest side to the project dimension (so you see the whole image), and fill will fit the shortest side to the project dimensions (so the image covers the entire camera view).
- Wes
ImageImageImage
User avatar
synthsin75
 
Posts: 6997
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma

Re: Scale layer to fit project?

Postby litote » Tue Feb 19, 2019 8:09 am

synthsin75 wrote:Here's a menu script I just wrote to make an image layer either fit or fill the project dimensions: https://sites.google.com/site/synthsin/ ... ects=0&d=1

Fit will fit the longest side to the project dimension (so you see the whole image), and fill will fit the shortest side to the project dimensions (so the image covers the entire camera view).



Thanks! Could you give me some instructions on how to install the script and use it in Moho 12? I am new to this.
litote
 
Posts: 30
Joined: Mon Feb 18, 2019 12:16 pm

Re: Scale layer to fit project?

Postby Greenlaw » Tue Feb 19, 2019 5:31 pm

litote wrote:Thanks! Could you give me some instructions on how to install the script and use it in Moho 12? I am new to this.

I haven't tried the script yet but to install, launch Moho and select Open Custom Content Folder under File. Assuming you set this folder when you installed Moho, it will open the folder. Open Scripts, then Menu. In here, drop the script into one of these folders or create a new one for third party scripts. (I have a folder in there called +Special for custom scripts, and inside there I have a few folders named after developers, Synthsin75 in this case. The '+' puts this menu at the top of the list.)

Back in Moho, press ctrl+shift+alt+L. This refreshes the scripts used by Moho.

Now, under the Scripts menu, you'll see the new command.

@Wes, thanks for creating this. I'll try it out later today.
User avatar
Greenlaw
 
Posts: 4210
Joined: Mon Jun 19, 2006 5:45 pm
Location: Los Angeles

Re: Scale layer to fit project?

Postby synthsin75 » Tue Feb 19, 2019 7:37 pm

I've updated the script (same link) to include cropping the project to the image dimensions (which was a standalone script I wrote a few years ago).

You can check what each button does and hit Cancel to undo any changes.
- Wes
ImageImageImage
User avatar
synthsin75
 
Posts: 6997
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma

Re: Scale layer to fit project?

Postby Greenlaw » Tue Feb 19, 2019 7:49 pm

Sounds great, Wes! I tried the earlier version this morning and it seemed to work well. Will give this new one a run at lunchtime.

BTW, I'm interested in studying your code for this script. As you know, I've been trying to learn Lua for Moho for some time now, and what you've done here seems to be be related to a tool I've been working on. May I pick your brain on this if I get stuck? :)
User avatar
Greenlaw
 
Posts: 4210
Joined: Mon Jun 19, 2006 5:45 pm
Location: Los Angeles

Re: Scale layer to fit project?

Postby synthsin75 » Tue Feb 19, 2019 8:28 pm

Greenlaw wrote:BTW, I'm interested in studying your code for this script. As you know, I've been trying to learn Lua for Moho for some time now, and what you've done here seems to be be related to a tool I've been working on. May I pick your brain on this if I get stuck? :)


If so, you probably want to study the first version (which I didn't keep a copy of), as the updated code isn't as straight forward.

Yeah, I'm always happy to help.
- Wes
ImageImageImage
User avatar
synthsin75
 
Posts: 6997
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma

Re: Scale layer to fit project?

Postby Greenlaw » Tue Feb 19, 2019 8:31 pm

Thanks for the tip! I still have the previous version on my laptop and will be sure to back it up for study.
User avatar
Greenlaw
 
Posts: 4210
Joined: Mon Jun 19, 2006 5:45 pm
Location: Los Angeles

Re: Scale layer to fit project?

Postby Greenlaw » Tue Feb 19, 2019 9:18 pm

I had been commenting each line in your first script to be sure I understood what is happening. I think I was doing ok--only a little difficulty so far--but I'm looking at the first version now, and you're right, this one is much easier for me to follow. Will start here first. :)
User avatar
Greenlaw
 
Posts: 4210
Joined: Mon Jun 19, 2006 5:45 pm
Location: Los Angeles

Re: Scale layer to fit project?

Postby synthsin75 » Tue Feb 19, 2019 9:56 pm

The code for just the cropping is here: http://mohoscripting.com/snippets/3
- Wes
ImageImageImage
User avatar
synthsin75
 
Posts: 6997
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma

Re: Scale layer to fit project?

Postby Greenlaw » Tue Feb 19, 2019 11:24 pm

Thank you, Wes! One of the tools I'm working on can make use of the cropping snippet.

I'm also trying to port a tool I made for After Effects to Moho. I created that one using Javascript, and parts of your ImageFitFill script is helping me figure out how to convert parts of the script for lua.

Whenever I get these done, I'll be sure to share them with everybody.

Since we're getting a little OT now, I'll continue this discussion over in the Scripting area.
User avatar
Greenlaw
 
Posts: 4210
Joined: Mon Jun 19, 2006 5:45 pm
Location: Los Angeles


Return to How Do I...?

Who is online

Users browsing this forum: No registered users and 1 guest