Common Image Processing Methods

Source: Internet
Author: User

Magickimage may have been used. It mainly processes some images and can process more than 90 image types. it is very powerful, and we mainly use its zoom, intercept, and copy functions in practical applications. Others, such as writing text, adding background color, and rotating... Use less.

The first common function Scaling (scaleimage ).

First, initialize an imageinfo object to load the image path to be processed.
Imageinfo info = new imageinfo ("F: // images // 1.jpg ");
Then, input the image information imageinfo as a parameter for constructing magickimage. Magickimage is the main category for processing images.
Magickimage image = new magickimage (Info );
Then select the magickimage object method. . Scaleimage (W, h). The first parameter is the scaled width, and the second parameter is the height.
Magickimage cropped = image. scaleimage (40, 80 );
Save the processed image name (1_scale.jpg) to the specified directory (F:/images ).
Cropped. setfilename ("F: // images // 1_scale.jpg ");
Writeimage specifies the imageinfo object of the source image.
Cropped. writeimage (Info );

In this case, the original image is simply scaled into a new image named "scale.jpg" of 40x80.

The second commonly used function truncation (cropimage ).

First, initialize an imageinfo object to load the image path to be processed.
Imageinfo info = new imageinfo ("F: // images // 1.jpg ");
Initialize a proper width and height, as well as the starting coordinate. It is the size and shape (rectangle) of the image to be processed ).
Rectangle rect = new rectangle (0, 0, 40, 80 );
X and Y are the coordinates of the starting point. Generally, starting from the upper left corner of the image, the default value is 0.w, and H is the actual width and height, not the width and height after proportional truncation.
This is different from the above.
Then, input the image information imageinfo as a parameter for constructing magickimage. Magickimage is the main category for processing images.
Magickimage image = new magickimage (Info );
Then select the magickimage object method. Truncate the actual size. Cropimage (rect). The parameter indicates the image range.
Magickimage cropped = image. cropimage (rect );
Save the processed image name (1_crop.jpg) to the specified directory (F:/images ).
Cropped. setfilename ("F: // images // 1_crop.jpg ");
Writeimage specifies the imageinfo object of the source image.
Cropped. writeimage (Info );

In this case, the original image is simply taken as a new crop.jpg image of 40x80. The size of the original image must be greater than 40x80. Otherwise, the screenshot is blank. Try it on your own.


The last common function copy is the simplest.
 
First, initialize an imageinfo object to load the image path to be processed.
Imageinfo info = new imageinfo ("F: // images // 1.jpg ");

Then, input the image information imageinfo as a parameter for constructing magickimage. Magickimage is the main category for processing images.
Magickimage image = new magickimage (Info );

Save the processed image name (copy.jpg) to the specified directory (F:/images ).
Image. setfilename ("F: // images // your copy.jpg ");
Writeimage specifies the imageinfo object of the source image.
Image. writeimage (Info );
This method is not used (cloneimage). It can be simply understood as changing the storage path of the image. This makes it easier to copy the image, which is much simpler than its built-in cloneimage.

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.