Page 1 of 1
split image to 100X200 form 4800
Posted: 2013-04-26T23:09:42-07:00
by mathew
Hi All,
I have a pic that is 4800X4800 , how can I split it to 100X200 images ? can I do this Automatically?
Math
Re: split image to 100X200 form 4800
Posted: 2013-04-26T23:51:18-07:00
by snibgo
Code: Select all
convert pic.png -crop 100x200 +repage x-%03d.png
This will create x-000.png, x-001.png etc.
Re: split image to 100X200 form 4800
Posted: 2013-04-27T00:52:42-07:00
by mathew
yes this is the magic
.... work great !!!!
Re: split image to 100X200 form 4800
Posted: 2013-04-27T02:38:31-07:00
by snibgo
Good stuff.
Sadly, I can't count. You should get 48*24 = 1152 files, which needs 4 digits, so it is better to put %04d in the output file name. "%03d" will work, but most of the files will have 3 digits, with just the final 153 having 4 digits.
Re: split image to 100X200 form 4800
Posted: 2013-04-27T08:13:46-07:00
by glennrp
Be aware that the resulting images will all contain PNG vpAg and oFFs chunks to record the size of the canvas and the location of the image on the canvas. If you don't want those, use the "-repage" or "-strip" option.
Re: split image to 100X200 form 4800
Posted: 2013-04-27T08:24:12-07:00
by snibgo
"-repage"? I thought it was "+repage", as I used above?
Re: split image to 100X200 form 4800
Posted: 2013-05-01T00:06:37-07:00
by anthony
-repage 0x0+0+0 or
+repage
This resets canvas size (to image size) and the canvas offset.
I don't believe strip removes virtual canvas offsets.
As an alternative you can use
-crop @48x24
specifying the number of images wanted instead of size.
See Cropping into roughly Equally Sized Divisions
http://www.imagemagick.org/Usage/crop/#crop_equal
Re: split image to 100X200 form 4800
Posted: 2013-05-01T14:59:57-07:00
by glennrp
snibgo wrote:"-repage"? I thought it was "+repage", as I used above?
Oops. Yes, +repage (or as Anthony says, "-repage 0x0+0+0").
And yes, the page info in PNG vpAg and oFFs chunks does survive
the -strip operation. That's a recent change that I was not aware of; IM-6.8.5-0
strips them, while IM-6.8.5-2 preserves them. I guess that has to do with the recent
reorganization of properties and attributes.
edit: this seems to be fixed in 6.8.5-4.
Re: split image to 100X200 form 4800
Posted: 2013-05-01T18:28:07-07:00
by anthony
No -strip actually does remove those profiles, but the profile data is heavily used, so gets stored as image attributes.
(definition: an image attribute is a property stored as actual values rather than as a string)
But the coder recreates them based on the image attributes (not profile info).
Just as it sets those image attributes from the profile info, as the image is read in.
As such the canvas meta-data by passes -strip, and that is a good thing.
-strip is meant to remove extra or extraneous profiles that images do not actually need.