Skip to content

Instantly share code, notes, and snippets.

@hellocatfood
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hellocatfood/31d1dd44748bc9553fb2 to your computer and use it in GitHub Desktop.
Save hellocatfood/31d1dd44748bc9553fb2 to your computer and use it in GitHub Desktop.
Combine two images
Blind Combine
=============
Combines two images together by replacing every other pixel of a source image with a pixel from another image
--------------------------------------------------------------------------------------------------------------
(well, it will do eventually)
Developed as a way to epxlore remixing as part of the Archive Remix project http://archiveremix.tumblr.com/
Dependencies
============
- Imagemagick
#!/bin/bash
convert 2.png -crop 1x1 abc2.png
#width and height of image 1
width_1=$(identify-format "%w" "$1")
height_1=$(identify-format "%h" "$1")
#width and height of image 2
width_2=$(identify-format "%w" "$2")
height_2=$(identify-format "%h" "$2")
#need some method to make both images the same dimensions if they're not already. An attempt below:
if [ $width_2 != $width_1 ]
do mogrify -scale x"$width_1"! $2
if [ $height_2 != $height_1 ]
do mogrify -scale "$height_1"! $2
xoffset=0
yoffset=0
imageno=0
whatever=0
#get colour of target pixel from second image
color=$(convert $2 -format "%[pixel: u.p{"$xoffset","$yoffset"}]" info:)
#convert -size 100x100 xc:"$color" swatch.png
while [ $hoffset -le $(($height - 5)) ]
do
woffset=0
while [ $woffset -le $width ]
do convert -page "$width"x"$height" 1.png -page +"$woffset"+"$hoffset" abc2-"$imageno".png -layers flatten 1.png
imageno=$(($imageno + 2))
woffset=$(($woffset + 2))
done
echo $imageno
hoffset=$(($hoffset + 1))
done
rm abc*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment