Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How automate crops of an image
#13
(08-12-2020, 06:24 PM)rich2005 Wrote: Not Gimp using ImageMagick

Quote:I need to take different segmented crops of an image.  Say my image is 100 tall by 2000 wide (100x2000 pixels)
How do I automatically crop an image 100x750 starting x=0 and crop every 10 pixels and save each image to file?
quick-n-dirty bash script with fixed values, change as appropriate. wide.png is the 2000x100 image.
Code:
#!/bin/bash
for i in $(seq 0 10 90)
do
 convert wide.png -crop 750x100+$i+0 +repage "%02d"$i.png
done
for i in $(seq 100 10 990)
do
 convert wide.png -crop 750x100+$i+0 +repage "%01d"$i.png
done
for i in $(seq 1000 10 1250)
do
 convert wide.png -crop 750x100+$i+0 +repage $i.png
done

Thanks? I am not sure, lol.  I have not messed with bash chmod linux terminal commands in 10 yrs?  And then, it was just messing.  (and vi, I mean are we still using that?  Luckily a little clue ":q")  I came here for a little help and I think I am getting tortured lol.  Maybe I will just manually rectangle select and paste each one in gimp haha, no.  please have mercy.
I have been trying to figure this out, as all my barriers are stupid questions but I am getting wore out.

So I believe I have everything running correctly, I can run "magick wide.png win:" and it opens up in the image in image viewer

I am a long ways from getting the script to work,  the wide.png is in working directory
When I enter this line:
$ convert wide.png -crop 750x100+$i+0 +repage "%02d"$i.png
  it gives me the error:
Invalid Parameter - -crop
Reply


Messages In This Thread
How automate crops of an image - by stevem0 - 08-12-2020, 01:24 AM
RE: How automate crops of an image - by Ofnuts - 08-12-2020, 08:35 AM
RE: How automate crops of an image - by stevem0 - 08-12-2020, 02:20 PM
RE: How automate crops of an image - by Kevin - 08-12-2020, 02:47 PM
RE: How automate crops of an image - by denzjos - 08-12-2020, 02:49 PM
RE: How automate crops of an image - by stevem0 - 08-12-2020, 03:58 PM
RE: How automate crops of an image - by Ofnuts - 08-12-2020, 04:11 PM
RE: How automate crops of an image - by stevem0 - 08-12-2020, 03:23 PM
RE: How automate crops of an image - by Ofnuts - 08-12-2020, 03:46 PM
RE: How automate crops of an image - by stevem0 - 08-12-2020, 04:48 PM
RE: How automate crops of an image - by rich2005 - 08-12-2020, 06:24 PM
RE: How automate crops of an image - by stevem0 - 08-13-2020, 04:08 AM
RE: How automate crops of an image - by Ofnuts - 08-13-2020, 06:49 AM
RE: How automate crops of an image - by stevem0 - 08-13-2020, 11:51 AM
RE: How automate crops of an image - by stevem0 - 08-12-2020, 08:05 PM
RE: How automate crops of an image - by rich2005 - 08-13-2020, 07:04 AM
RE: How automate crops of an image - by rich2005 - 08-13-2020, 12:46 PM
RE: How automate crops of an image - by stevem0 - 08-13-2020, 08:58 PM

Forum Jump: