The result of this call is a again a BufferedImage object.
You can find the width and height of this image using the following
methods:

printf("Photo size is %d x %d\n, photo1.getWidth, photo1.getHeight)

You can save an image object into a file using:

ImageIO.write(photo2, "jpg", new File("test.jpg"))

or, if you prefer PNG format:

ImageIO.write(photo2, "png", new File("test.png"))

The pixels of a java.awt.image.BufferedImage object can be read
and changed using the getRGB and setRGB methods, see
below.

Example script

The following small script reads a file photo.jpg, get its
dimensions, creates a new empty image of the same size, copy the
pixels from the old image img to the new image out
(mirroring horizontally), draws a red line diagonally across the
photo, and finally saves the new image in a file test.jpg
(image.scala):

Colors

The method getRGB(x: Int, y: Int): Int returns the color of the
pixel at position (x, y), the method setRGB(x: Int, y:
Int, color: Int) sets the color of this pixel.

Colors are represented as Int objects. The three components
red, green, and blue are "packed" together into one integer. Each
component has 8 bits, and therefore can have a value between 0
and 255. The packed color is a 32-bit integer, whose bits look like
this:

tttt tttt rrrr rrrr gggg gggg bbbb bbbb

The top 8 bits are either zero, or represent the "transparency" of
the pixel. We will not use these transparency bits. The next 8 bits
represent red, the next 8 bits represent green, and the last 8 bits
represent blue. This is why this representation is called "RGB".

Given red, green, and blue components with values in the range 0
to 255, we can pack them together like this:

val color = (red * 65536) + (green * 256) + blue

Given a packed integer color, we can extract the three
components as follows: