Given a grid of images, generate single images
- Install imagemagick
- Run the convert command:
convert image.png -crop 2x3-8-8@ +repage +adjoin tile-%d.jpg
where:
image.png
is your screenshot file name6x3
is your grid layout-8-8
is the amount of horizontal and vertical padding around each imagetile-%d.jpg
will be the name of each image, with a number appended for each one generated, replacing the%d
(e.g. tile-1.jpg
)
Given a directory of single images, generate side-by-side image pairs for pix2pix model generation using montage:
montage tile-*.jpg -tile 2x1 -geometry 418x418+0+0 multi-%d.jpg
where:
tile-*
is the repeatable name of each image in the directory (e.g.tile-1.jpg, tile-2.jpg
, etc)2x1
creates sets of images with 1 row and 2 columns418x418
is the dimensions of each individual image0+0
is the amount of horizontal and vertical padding you want in between each image (we don't want any)multi-%d.jpg
is the output file name for each image pair.
For generating new images, we want to run pix2pix on a test set of images with a blank image as its pair:
for i in *.jpg; do
convert \
${i} \
-gravity west \
-background white \
-extent 836x418 \
$(convert ${i} -format "pair-%t.%e" info:)
done
where:
i in *.jpg
loops through all of our jpg images in order to run imagemagick'sconvert
command${i}
becomes the placeholder for that image path-gravity west \
implies we will be expanding our image canvas to the right (our image will be on the left / west side)-extent 836x418 \
gives the final desired dimensions of our images (418x2=836
pixels in width)$(convert ${i} -format "pair-%t.%e" info:)
runs the actual convert command, generating images with a name likepair-1.jpg
where%t
is the iterator, and%e
is the extension