Tiles and Cropping

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
gordieny

Tiles and Cropping

Post by gordieny »

I successfully created a set of tiles. I'm trying to create the same amount of tiles every time which works fine.

My problem is that each tiles retains it's exact position from the original file. In other words the image is "padded" from the left. So, when I load the image into html there is "space" on the left.

Is there a way to "trim" the image so each image would be in the top-left with not padding, ie (0,0) of the web page?

Here is the original instruction.

convert Don_Manuel.jpg -crop 33.3333333%x33.333% Don_Manuel_%d.gif
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Tiles and Cropping

Post by magick »

Add +repage to your command line to reset the virtual canvas.
gordieny

Re: Tiles and Cropping

Post by gordieny »

thanks so much!
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Tiles and Cropping

Post by anthony »

Just as a clarification. The image is NOT padded, but has a 'virtual offset'. The image itself is the right size, just positioned on the virtual canvas in the same place you cut it from. +repage resets the virtual canvas and offset information.

It is done this way to preserve positioning information, that way later layer work, or extracting that information for later work is possible. this is particularly important with the special -trim operator, which could have variable results that you may like to read.

See Triming Noisy Images which trims a blurred image, but then uses that to mask and trim the original unblurred image.

It is also vital to correct handling of GIF animation frame optimization.


Hmmm perhaps in IM v7 we will make -crop automatically do a +repage while +crop will preserve the virtual information. This would be inline with the -/+distort operator which has a similar use of the + version of the operator.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply