Draw rectangle on multipage TIF

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
nbsusa
Posts: 2
Joined: 2014-03-14T05:07:27-07:00
Authentication code: 6789

Draw rectangle on multipage TIF

Post by nbsusa »

I have a multipage tif image containing 50 pages. I need to draw rectangles on page 4 and save the multipage tif in the same page order. I've attempted many things with not much success. -clone does it somewhat but I can't figure out how to get the image I drew the rectangle on back in the correct sequence. I've also attempted using *.tif[4] for example also with no success.

Any ideas?

Here are two examples of attempts with no success:
1. Outputs only single page of 50 page TIF
convert "C:\01000014333.tif[3]" -fill "rgba(0,0,0,1)" -draw "rectangle 678,848,957,894" "C:\01000014333x.tif"

2. Outputs correct number of pages but the page with rectanagle is placed at end of sequence
convert "C:\01000014333.tif" ( -clone 3 -fill "rgba(0,0,0,1)" -draw "rectangle 678,848,957,894" ) -delete 3 "C:\01000014333x.tif"
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Draw rectangle on multipage TIF

Post by snibgo »

Taking your second example:

You read the 50 images. Then you clone number 3, so you now have 51 images, with the new one at the end. Then you delete number 3 so, as you say, the new one is still at the end.

I would swap the new image with number 3 ("-swap -1,3"), then delete the last one ("+delete").

Code: Select all

convert "C:\01000014333.tif" ( -clone 3 -fill "rgba(0,0,0,1)" -draw "rectangle 678,848,957,894" ) -swap -1,3 +delete "C:\01000014333x.tif"
An alternative method would "-delete 3", then "-insert 3".
snibgo's IM pages: im.snibgo.com
nbsusa
Posts: 2
Joined: 2014-03-14T05:07:27-07:00
Authentication code: 6789

Re: Draw rectangle on multipage TIF

Post by nbsusa »

Perfect! Thank you very much!
Post Reply