Unless I have missed something like a space after the \, your command looks OK to me other than possibly adding +repage after the -trim. So I am not sure what the issue might be. Possibly missing or corrupt image? Which image is first, the larger or the smaller?
I tried this and it ran without error:
convert logo: \( logo: -gravity center -crop 128x128+0+0 \) \
\( -clone 0 -clone 1 -compose difference -composite -threshold 0 \) \
-delete 1 -alpha off -compose copy_opacity -composite -trim +repage \
logo_test.png
The above gave me the logo image with a transparent 128x128 area in the center
But when I ran this, I got the following error:
convert \( logo: -gravity center -crop 128x128+0+0 \) logo: \
\( -clone 0 -clone 1 -compose difference -composite -threshold 0 \) \
-delete 1 -alpha off -compose copy_opacity -composite -trim +repage \
logo_test.png
convert: geometry does not contain image `LOGO' @ warning/attribute.c/GetImageBoundingBox/239.
Nevertheless, I am not sure if that is really a valid way to find the offset.
However, you can find where a subimage is located in a larger image using the
compare function.
see
http://www.imagemagick.org/script/compare.php
http://www.imagemagick.org/Usage/compare/#compare
http://www.imagemagick.org/Usage/compare/#sub-image
viewtopic.php?f=1&t=14613&p=51076&hilit ... ric#p51076
in the latter, the new convention is to use -subimage-search to force compare to consider a smaller and larger image rather than just the difference between two images of the same size. See the link above ending in /#sub-image
What version of IM. You may need to upgrade to get the subimage compare with the correct syntax as the -subimage-search option was added in 6.6.3-6, though prior to that you could do subimage search without it as far back as 6.5.0-9