Copy and paste .tiff parts

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
cletcher

Copy and paste .tiff parts

Post by cletcher »

Hi there. I am a complete noob to this, thanks in advance for the help.

I am trying to take a given piece of a .tiff image and over write the same section of a different, identically sized image. If this can be done in 1 or two steps that would be great.

Thanks again!
Chris
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Copy and paste .tiff parts

Post by anthony »

What do you mean by the same section?

If the image is the same size (without transparency) over writing the other image will just replicate the original image.

However try this

Code: Select all

   convert overlay.tiff background.tiff  result.tiff
For more see IM Examples, Alpha Composition
http://www.imagemagick.org/Usage/compose/
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
cletcher

Re: Copy and paste .tiff parts

Post by cletcher »

Thanks for the reply. That's not quite what i'm looking to do. I'll try to be more clear.

If the total size of both images was 400X1000, I would like able to take a piece of it like 100X100 to 300X300 (a 200X200 square) of the first image and paste it in the same spot on the second image without altering the rest of the second image.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Copy and paste .tiff parts

Post by anthony »

Oh... Thatsi quite easy... crop and flatten, don't remove the offset from the cropped image!

Code: Select all

convert  image1.tiff   -crop 200x200+100+100 \
             image2.tiff  +swap  -background none -flatten \
             output.tiff
the +swap in the above is to re-order the images so the second image is under the first. The -background is NOT needed if the images are fully opaque (no transparency).

An alturnative is....

Code: Select all

convert  image2.tiff  \( image1.tiff   -crop 200x200+100+100 \) \
             -composite  output.tiff
This uses parentheses rather than swapping image order. without the parenthesis the crop would crop BOTH images. It then uses -composite to combine just those two images.

See IM Examples, "Basics" for image ordering and parenthesis, and "Mosaics" for Flattening a sequence of two or more images on top of each other. Also look and "Alpha Composition" for more of the composition operators.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
cletcher

Re: Copy and paste .tiff parts

Post by cletcher »

Perfect, thanks!
cletcher

Re: Copy and paste .tiff parts

Post by cletcher »

What would be the easiest way to determine the co-ordinates of the area that I wish to crop?
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Copy and paste .tiff parts

Post by anthony »

Launch some image editor and write down the coordinates. I use a very old program called XV which pressing the middle button on the image pops up color and position information.

I am also planing some PerlTk type of programs to display images, and locate coordinates and do trial Magick runs to do manual panarama composite image registration (finding specific matching points in two images).
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply