split image to 100X200 form 4800

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
mathew
Posts: 2
Joined: 2013-04-26T23:04:57-07:00
Authentication code: 6789

split image to 100X200 form 4800

Post 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
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: split image to 100X200 form 4800

Post by snibgo »

Code: Select all

convert pic.png -crop 100x200 +repage x-%03d.png
This will create x-000.png, x-001.png etc.
snibgo's IM pages: im.snibgo.com
mathew
Posts: 2
Joined: 2013-04-26T23:04:57-07:00
Authentication code: 6789

Re: split image to 100X200 form 4800

Post by mathew »

yes this is the magic :).... work great !!!!
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: split image to 100X200 form 4800

Post 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.
snibgo's IM pages: im.snibgo.com
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: split image to 100X200 form 4800

Post 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.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: split image to 100X200 form 4800

Post by snibgo »

"-repage"? I thought it was "+repage", as I used above?
snibgo's IM pages: im.snibgo.com
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: split image to 100X200 form 4800

Post 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
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: split image to 100X200 form 4800

Post 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.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: split image to 100X200 form 4800

Post 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.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply