A
A
AlexeyMoshkin2014-11-24 17:30:14
bash
AlexeyMoshkin, 2014-11-24 17:30:14

How to cut many images by coordinates?

I wonder how to automate the process of cutting many .tif images from one .tif image, if there are coordinates of the upper left corner of each of these images in a format, for example, excel or simply listed in a text document.
I'm going to use ImageMagick's convert -crop, and the question arises, how can I pass a lot of coordinates there instead of entering them manually?
All cut out images are the same size, square.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Armenian Radio, 2014-11-24
@AlexeyMoshkin

Write a bash script that will read your text document and call imageMagic:

IFS=','
while read i val; do
  вызов imageMagic $i, $val #$i - первый размер $val - второй размер
done < input.txt

the values ​​of the coordinates of the corners must be in the lines of the input.txt file, separated by commas:
0,100
100,200

S
Sergey Lerg, 2014-11-24
@Lerg

Obviously write a small script. On bash it is most likely possible to do this, but I would use Python.
He always helps me out where bash can't.
You can use both the PIL library and call convert for each image.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question