Page 1 of 1

Draw rectangle on multipage TIF

Posted: 2014-03-14T05:20:02-07:00
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"

Re: Draw rectangle on multipage TIF

Posted: 2014-03-14T06:13:17-07:00
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".

Re: Draw rectangle on multipage TIF

Posted: 2014-03-14T06:17:43-07:00
by nbsusa
Perfect! Thank you very much!