Search code examples
imagemagickim4java

crop options in imagemagick?


I'm using im4java api to crop images. I never used command-line for imagemagic.

there are function, crop(int width,int height,int x, int y, String special) crop(int width,int height,int x, int y, Character special)

I can understand, what are first 4 parameters(height, width, x ,y) for. Can anybody explain to me, what are that fifth parameters (String special and Character special) for?

and what are the possible values? Their documentation is clueless.


Solution

  • I think the authours probably expect users to be familiar with the command-line version of ImageMagick...

    I don't know if this answer is correct, I am just assuming that it is related to the special operators available on the command line after the geometry/size settings. Some of these are:

    < - shrinks images with dimensions less than those given, ignoring larger ones

    > - shrinks images with dimensions larger than those given, ignoring smaller ones

    ! - which ignores aspect ratio and focres exact output size

    @ - which specifies the total number of pixels (i.e. area) of the output image, regardless of whether the image is tall or wide. So, @1000 will produce an image with somewhere between 1000x1, 1x1000 or 33x33 but never with more than 1,000 pixels in toto.

    % - allows you to resize by percentage, i.e. 50% which saves you having to get the dimensions and then do some maths.

    There is a fuller list here.