I generated many figures in .png format (approximately 120). Right now I need to pair the figures on a single page so that the files with the same file name (i.e. jack) that end with .matrix.png are placed on the left and .cdt.png is on the right (so jack.matrix.png with jack.cdt.png etc... many names). I was doing this using powerpoint and it is taking forever. I was wondering if there is some sort of short cut (command line or whatever) that can join the two images together. The file format of the output can be anything (.png, jpg, .ppt, etc).
The convert utility which is a part of imagemagick will do what you need. Basic command line is:
convert +append image1.jpg image2.jpg product.jpg
The two images are placed side by side; use -append for a 'top to bottom' arrangement. With this you can easily write a script to process all of the files.
If you don't already have it installed, this might be a good starting point:
thanks it turns out I have the command function. So how would i do it for all the files simultaneously or consecutively (i.e. all files that match with the initial name e.g. joe.matrix.png matched with joe.cdt.png.... jack.matrix.png with jack.cdt.png)
If you have imagemagick installed this script should join your two images:
for left in *.matrix.png
do
right=${left/matrix.png/cdt.png}
result=${left/matrix.png/joined.png}
[ -f "$right" ] && convert "$right" "$left" +append "$result"
done
Thanks for the reply but I made a mistake in my explanation. I also need the initial names prior to the .cdt.png or .matrix.png to match. So if the name of the file is joe.cdt.png then I would want it to match joe.matrix.png. There are over 100 files with different names that need to be matched up and doing this manually is quite troublesome. Any help would be great
Thanks
---------- Post updated at 11:40 AM ---------- Previous update was at 12:26 AM ----------
Hi not sure if anyone can help me modify this code I wrote. Again I am trying to join two files that share the same name but different ending
for f in *.cdt; do var=`echo "$f" | sed 's/\.cdt$//'`; convert +append $var.cdt.png $var.matrix.png $var_merged.png; done