1

I have 6,000 pictures with two horizontal bars of text in them, one at the top, one at the bottom.

The goal is to cut the top bar and put it under the bottom bar of text. How would I do that in a batch process? I know XnView can cut pictures in half and crop them in a batch process, but the trick seems to be to stitching them back together in batch.

My input is shown on the left; the desired result is shown on the right:

From the left picture to the picture on the right

EDIT: I am, frankly, baffled that you would describe this as "too broad". I tried to keep it general, because EVERY TIME I mention a program, you jump on my neck and scream about too specific, "asking for opinions about one program vs another" so, perhaps you people should decide whether you want to hear about individual programs or not.

What I tried is using Corel's PaintShop Pro to cut ONE picture, but I lack the time to do that for 6,000+ pictures.

I then tried XnView, but that does only has a cutting function, not a "stitch back together" function.

If you just don't understand what I am asking, please say so.

4
  • 3
    Please note that superuser.com is not a free script/code writing service. If you tell us what you have tried so far (include the scripts/code you are already using) and where you are stuck then we can try to help with specific problems. You should also read How do I ask a good question?.
    – DavidPostill
    Commented May 11, 2019 at 15:54
  • 2
    The tools you likely need are ImageMagick and possibly something like Python (though most any scripting language would likely do -- Python might be overkill here). In any case, ImageMagick can do the cutting and concatenation you require from the command line. Commented May 11, 2019 at 19:48
  • 1
    1. How uniform are the images? Are they all the same dimensions and the top text bar is exactly the same size? That detail makes a huge difference in the scope of any solution, and the question doesn't address that. 2. "Too broad" can apply to the required solution. Developing a working solution for this is outside the intended scope of a question. See the 1st comment.
    – fixer1234
    Commented May 11, 2019 at 23:31
  • 3
    If the height of the top text bar is known (for example, 25 pixels) this can be done with ImageMagick's roll command: convert input_file -roll +0-25 output_file Commented May 12, 2019 at 2:37

1 Answer 1

2

Microsoft Windows [Version 10.0.17134.706]

Download Imagemagick for Windows

REM MOVE A ROW 32 PIXELS TALL STARTING FROM 0,0 TO THE BOTTOM USING ROLL
"%ProgramFiles%\ImageMagick-7.0.7-Q16\convert.exe" "%USERPROFILE% \Desktop\IQ1Xi.jpg" -roll +0-32 "%USERPROFILE%\Desktop\IQ1Xi2.jpg"
REM BRING THE TEXT CLOSER TOGETHER BY MAKING TWO CROPS OF IQ1Xi2.jpg AND -APPEND THEM
REM CROP 1
"%ProgramFiles%\ImageMagick-7.0.7-Q16\convert.exe" "%USERPROFILE%\Desktop\IQ1Xi2.jpg" -crop 352x204+0+0 "%USERPROFILE%\Desktop\IQ1Xi3.jpg"
REM CROP 2
"%ProgramFiles%\ImageMagick-7.0.7-Q16\convert.exe" "%USERPROFILE%\Desktop\IQ1Xi2.jpg" -gravity South -crop 352x24+0+0 "%USERPROFILE%\Desktop\IQ1Xi4.jpg"
REM FINISHED IMAGE USING -APPEND
"%ProgramFiles%\ImageMagick-7.0.7-Q16\convert.exe" "%USERPROFILE%\Desktop\IQ1Xi3.jpg" "%USERPROFILE%\Desktop\IQ1Xi4.jpg" -append "%USERPROFILE%\Desktop\IQ1Xi5.jpg"

ORIGINAL IMAGE:

Original

ROLLED IMAGE:

ROLLED

BRING THE TEXT CLOSER TOGETHER BY MAKING TWO CROPS OF THE ROLLED IMAGE AND -APPEND THEM.

CROP ONE:

CROP ONE

CROP TWO:

CROP TWO

FINISHED IMAGE:

APPENDED IMAGE

More info:

https://www.imagemagick.org/script/command-line-options.php#roll
https://www.imagemagick.org/script/command-line-options.php#crop
https://www.imagemagick.org/script/command-line-options.php#gravity
https://www.imagemagick.org/script/command-line-options.php#append

A BATCH FILE TO PROCESS ALL THE IMAGES:

Processing .jpg (roll, crop, & append) can degrade them so best off starting with not overwriting. Copy all your images to "%USERPROFILE%\Desktop\New folder\"

@echo off
SETLOCAL ENABLEEXTENSIONS
cd "%USERPROFILE%\Desktop\New folder\"
md "%USERPROFILE%\Desktop\New folder\processed\"
for /f "tokens=*" %%x in ('dir /b "%USERPROFILE%\desktop\new folder\*.jpg"') do (
"%ProgramFiles%\ImageMagick-7.0.7-Q16\convert.exe" "%%x" -roll +0-32 "%TEMP%\1.jpg"
"%ProgramFiles%\ImageMagick-7.0.7-Q16\convert.exe" "%TEMP%\1.jpg" -crop 352x204+0+0 "%TEMP%\2.jpg"
"%ProgramFiles%\ImageMagick-7.0.7-Q16\convert.exe" "%TEMP%\1.jpg" -gravity South -crop 352x24+0+0 "%TEMP%\3.jpg"
"%ProgramFiles%\ImageMagick-7.0.7-Q16\convert.exe" "%TEMP%\2.jpg" "%TEMP%\3.jpg" -append "%USERPROFILE%\Desktop\New folder\processed\%%x"
)
exit /b 
1
  • Thanks! Given the usual hostility here, i didn't expect a relevant answer. Will report back if it works ASAIC Commented Sep 22, 2019 at 2:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .