After using JES to make changes to your image, make sure you know how to save your finished work.
JES is a programming environment that uses the Jython programming language. It provides an easy-to-use interface for writing, running, and debugging code.
You can use JES to edit various media such as photos, videos, and sounds. JES also provides many built-in libraries and functions. These aid in certain tasks, such as changing the color of pixels in an image.
Once you have finished editing your image, you can save it to your local computer.
How to change the sample image
Images can be imported, rendered, and edited in JES.
- Open the JES application on your computer.
- In the programming window, create a new function named savePictureToFile().
def savePictureToFile():
- Inside this function, I display the file manager and prompt the user to select a file. Don’t forget to indent your code as part of the Jython structure.
file = pickAFile()
- Create a new image object from the selected file.
pic = makePicture(file)
- Make some changes to change the image. For example, you can use JES to add text to an image. To do so, start by importing “java.awt.Font” to use the styled font.
import java.awt.Font as Font
- Create and style the text you want to appear on the image. Add text to the image with a specific set of coordinates using the addTextWithStyle() function.
str = "Text added to modify image"
styledFont = makeStyle("Arial", Font.BOLD, 96)
addTextWithStyle(pic, 200, 200, str, styledFont)
How to save a new image to your computer
You can use the built-in writePictureTo() function to save the new image as a new file on your computer.
- Still inside the savePictureToFile() function, after editing the image, add a variable to save the file path. The details depend on the operating system and file system structure. Here is an example path to the desktop folder on a Windows machine:
pathToDesktop = "C:\\Users\\Sharl\\Desktop\\"
- Add a variable to store the name of the newly saved image.
newFileName = "newPic.jpg"
- Save the new image as a file using the built-in writePictureTo() function. Pass the image you want to save to the function along with the full file path where you want to save it.
fullPath = pathToDesktop + newFileName
writePictureTo(pic, fullPath) - To run the Jython script, program load A button between the programming area and the terminal.
- Type the name of the function into the terminal and run it.
savePictureToFile()
- Select an image using your file manager.
- Go to your desktop to see a new image file with your changes added to the photo.
Editing Images Using JES
With JES, you can easily change the image programmatically and save the results. Environments offer many interesting techniques for image processing.