Page 1 of 1

Inserting blank lines between parts of an image

Posted: 2017-08-29T09:22:42-07:00
by jwes
I have a number of images that are 536x536 pixels. I want to insert 10 pixels of blank space every 67 pixels while shifting the rest of the image down. The result should be images that are 536x606 pixels as below. Can someone help me do this?

Original
67 pixels image
67 pixels image
67 pixels image
67 pixels image
67 pixels image
67 pixels image
67 pixels image
67 pixels image

New
67 pixels image
10 pixels blank
67 pixels image
10 pixels blank
67 pixels image
10 pixels blank
67 pixels image
10 pixels blank
67 pixels image
10 pixels blank
67 pixels image
10 pixels blank
67 pixels image
10 pixels blank
67 pixels image

Re: Inserting blank lines between parts of an image

Posted: 2017-08-29T09:44:24-07:00
by fmw42
What is your IM version and Platform? Please alway provide that when asking question since syntax may vary, especially if scripting. Once we know that, we can probably help.

See the top-most post in this forum "IMPORTANT: Please Read This FIRST Before Posting" at viewtopic.php?f=1&t=9620

For novices, see

viewtopic.php?f=1&t=9620
http://http://www.imagemagick.org/scrip ... essing.php
http://www.imagemagick.org/Usage/reference.html
http://www.imagemagick.org/Usage/

Re: Inserting blank lines between parts of an image

Posted: 2017-08-29T09:51:52-07:00
by snibgo
What version of IM? I'll assume v6. For v7, use "magick" instead of "convert".

What platform? But that makes no difference to my suggestion.

Code: Select all

convert -size 536x536 gradient: -crop 0x67 -background None -gravity North -extent 0x77 -append -crop 0x606+0+0 +repage out.png
"-size 536x536 gradient:" makes a sample input image. You would use your own file.

Then I crop into multiple images, each 67 pixels high. I extend each downwards to 77 pixels height, with the extra rows colour "none", which is transparent black. Then I append these vertically. The result has an extra 10 rows at the bottom, so the final "-crop" removes them.

Re: Inserting blank lines between parts of an image

Posted: 2017-08-29T10:12:19-07:00
by fmw42
input image (dimensions 640x480)

Image

Code: Select all

convert logo.png -crop 640x67 +repage -gravity south -background none -splice 0x67 -append -chop 0x10 logo_stripe.png
Image

see
http://www.imagemagick.org/Usage/crop/#crop_tile
http://www.imagemagick.org/Usage/crop/#splice
http://www.imagemagick.org/Usage/crop/#chop

Re: Inserting blank lines between parts of an image

Posted: 2017-08-29T13:47:37-07:00
by GeeMack
jwes wrote: 2017-08-29T09:22:42-07:00I have a number of images that are 536x536 pixels. I want to insert 10 pixels of blank space every 67 pixels while shifting the rest of the image down. The result should be images that are 536x606 pixels as below. Can someone help me do this?
There are several ways to go about this task. Look over the good solutions fmw42 and snibgo have provided above. Here's another similar approach...

Code: Select all

convert input.png -alpha set -crop 0x67 -bordercolor none -border 0x5 -append -shave 0x5 output.png
That uses "-crop 0x67" to cut your input image into slices of the full width and 67 pixels high. Then it sets the border color to "none" and uses "-border 0x5" to add a 5 pixel transparent border to the top and bottom of each piece. Next it uses "-append" to re-assemble the pieces vertically. It eliminates the extra 5 pixels from the top and bottom of the final image using "-shave 0x5". Then it finishes by giving it an output file name.

If you're using IM7 you would start the command with "magick" instead of "convert".

Re: Inserting blank lines between parts of an image

Posted: 2017-08-30T13:04:18-07:00
by jwes
Thank you all for the help.