This ensures that small images don't get enlarged, which would reduce the quality. If the current document width (accessed through current_document.width) is less than the new width, don't resize. An if statement is wrapped around the resize method. Here's the code: current_document = app.activeDocument Let's modify the code so that any images smaller than the new size won't get resized. Fortunately, JavaScript is a very flexible language! This code works very well at resizing images to 670px (or whatever size you changed it to), but it could be better. Now that you have an understanding of Photoshop Scripts, it's time to improve the code. This can be found in the Presets > Scripts folder of your Photoshop installation. If you would like to see your script in this script menu, then you need to copy it into the appropriate folder. Navigate to your script, and then press open. If you don't want to tie your script to an action, it's even easier to setup. This menu is also where you can edit or delete any scripts previously configured. Go ahead and choose an event, which will trigger your script. Action: If you're not using a script, you can choose a basic action to perform instead, such as save to PDF.There are a few basic ones built in, but you can also assign one of your own scripts here. You can choose from a variety of options, such as when printing, when opening a new document, and many more. Photoshop Event: This is when the script will run. Once enabled, this interface allows you to configure existing scripts to run when certain actions occur. If you're writing scripts for other Adobe apps, you can change this to those instead. Now that you understand the code, it's time to run it! Ensure you have Photoshop open, along with a document.Īt the top of the ExtendScript Toolkit, change the target dropdown menu (top left) from ExtendScript Toolkit CC to Adobe Photoshop CC 2017 (or whatever your particular version of Photoshop is). Remember to capitalize these when using them in your code. Bicubic Sharper: An enhanced version of Bicubic designed for downsampling (making smaller).Bicubic Smoother: An enhanced version of Bicubic for upscaling (making larger).Bicubic: Very good results, but computationally expensive.Bilinear: Better than Nearest Neighbor, but slower and not as good as Bicubic.Here's a quick summary of the differences: These all vary in terms of speed and quality, so play around with them (although Bicubic is fine for most purposes). There are five main resampling methods available to you.
0 Comments
Leave a Reply. |