Using GraphicsMagick in Im4java

Source: Internet
Author: User

1. Defining actions and commands
Gmoperation op = new Gmoperation ();
Graphicsmagickcmd cmd = new Graphicsmagickcmd ("Convert"); Convert shows that what you're going to do is convert the action inside
or convertcmd cmd = new Convertcmd (true); True indicates that you are using a GM tool

2. Parameter description for Scaling
op.resize (int width)//It writes width, which makes me think that I can limit the width, not actually, but to limit the length and width beyond width.
op.resize (int width, int height)//actually is equivalent to limit a box, picture and other proportions placed in the box
If you want to implement the picture in the box, but is filled with a box, which will appear stretched, then call
Op.resize (width, height, '! ');


3. Image format for input and output
"1" You already have a picture of the local, you just need to tell the original path and the path of the newly generated image after the transformation OK
Op.addimage (Srcpath);
Op.addimage (NewPath);
Cmd.run (OP);
Or
Op.addimage ();
Op.addimage ();
Cmd.run (Op,srcpath,srcpath);
So finish writing the picture processing module and finish it.


"2" Your original image is just an input stream, and your output image only wants an output stream
Op.addimage ("-"); Read from stdin
Op.addimage ("jpg:-"); Write to stdout in Jpg-format Note that the JPG here can be changed according to your image format, but you have to have it, otherwise you do not know you want to create the converted image in including style
Pipe Pipein = new pipe (is, null);
Pipe pipeout = new pipe (null, OS);
Cmd.setinputprovider (Pipein);
Cmd.setoutputconsumer (pipeout);
Cmd.run (OP);


So you can implement the picture output stream you want.

Using GraphicsMagick in Im4java

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.