Do you think cloud development can only be used in wechat mini program? You might be OUT!

You think cloud development is just basic services? You might be OUT!

Cloud development not only supports multi-terminal (wechat applets, Web applications, APP applications, QQ applets), but also provides rich expansion capabilities!

Now, based on cloud development, you no longer need to carry out complex configuration and debugging, you can efficiently call other services and resources on Tencent cloud!

Have what kind of desire, have what kind of ability, cloud development expansion ability official release!!

CloudBase is a product solution of cloud integration. It adopts serverless architecture, eliminates operation and maintenance transactions such as environment construction, supports one cloud and multiple terminals, and helps to quickly build small programs, Web applications and mobile applications.

Why? – save trouble

Here’s an example:

To call image processing for example, Tencent cloud image processing capabilities for developers to provide intelligent cutting, lossless compression, format conversion and other functions.

Under the current mode, if you want to invoke the image processing capability of Tencent Cloud data Vientiane, you need to create COS bucket, purchase cloud host, complete environment construction, obtain access key, and then introduce COS SDK. But you can’t call the SDK yet! You also need to set up access systems!

And based on cloud development, the above steps are not required, just in Tencent cloud development console “one key installation”, you can call the image processing ability!

What expansion capabilities are available now?

More than half of developers use cloud storage for image storage, but in many cases, different application scenarios have different requirements for the same image (such as size, image quality, image format, image watermarking, etc.), and offline manual image processing takes a long time, which cannot meet the needs of diversified services. Or in the spirit of “more trouble to develop applications” for everyone, cloud development of the first phase of expansion capacity, the introduction of a series of rich image processing capabilities.

The image processing Image Processing provides a variety of image processing functions, including intelligent cropping, lossless compression, watermarking, format conversion, etc. You can easily manage files through the extended SDK.
Image security audit Image security audit provides a variety of sensitive content audit services, such as pornography, politics, violence and terrorism, to effectively identify prohibited pictures and avoid violations.
Image blind watermarking The blind watermark function adds the watermark image to the original image information in an invisible form, which does not affect the quality of the original image much. After the image is stolen, you can perform blind watermark extraction on the suspected stolen resources to verify the image ownership.
The image tag Icon label Identifies the image label of the storage data in cloud storage and returns the theme label with high confidence in the image to help developers analyze images.

Is it expensive? — Check out the free allowance

Image expansion capability free quota

The image processing 10 TB/month
Image security audit 2000 / day
Image blind watermarking 3000 / month

Free credits for cloud development

How does it work?

In an image processing scenario, there are two ways for developers to perform related image processing operations:

Basic image processing (such as intelligent cropping, lossless compression, watermarking, format conversion, etc.) by adding URL parameters: developers only need to add processing rules after accessing the address to obtain the processing results.

Advanced image processing (such as image security review and blind image watermarking) is performed by invoking SDK: Cloud development provides cloud and client SDK support, and file read and write permission policies are consistent with cloud storage, minus additional permission management for developers.

Cloud development image processing extension capabilities Quick Start

Next, call image blind watermarking as an example to teach you how to quickly use cloud development extension capabilities.

Results show

1. Prepare materials

2. Add a watermark

Image after adding watermark, FIG. 3. As can be seen from Figure 3, the appearance of the original image is not affected after the watermark is added.

3. Verify watermark extraction

When we extract the watermark image from Figure 3 above, the extracted watermark result is shown in Figure 4. It is not difficult to find that the extracted result image is basically the same as the watermark image, which can be used for copyright ownership verification.

If part of Figure 3 is captured, as shown in Figure 5, and the watermark is extracted to get Figure 6, the watermark can still be clearly identified, which is convenient for copyright protection.

Practical operation

1. Install the extension

1. Open the cloud Development extension console

2. Select the extension you want to install

2. Install the extended SDK into the project

npm install --save @cloudbase/extension-ci@latest
Copy the code

3. Invoke the extension SDK

Depending on the situation, the developer can choose to use the extension capabilities in the client or in the cloud. Client use:

const extCi = require("@cloudbase/extension-ci");
const tcb = require("tcb-js-sdk");
const readFile = async function(file) {
  let reader = new FileReader();
  let res = await new Promise(resolve => {
    reader.onload = function(e) {
      let arrayBuffer = new Uint8Array(e.target.result);
      resolve(arrayBuffer);
    };
    reader.readAsArrayBuffer(file);
  });
  return res;
};
let file = document.getElementById("selectFile").files[0];
let fileContent = await readFile(file);
Copy the code

Used in cloud functions:

const extCi = require("@cloudbase/extension-ci");
const tcb = require("tcb-admin-node");
letfileContent = imageBuffer; / / Uint8Array | Buffer format image contentCopy the code

Code sample

tcb.init({
  env: "Your environment ID"
});
tcb.registerExtension(extCi);

async function addWaterMark() {
  try {
    const opts = {
      rules:
      [
        {
          fileid: "/watermark/demo_image2.jpeg", rule: {// add watermark rule mode: 3,type: 2,
            image: 'mark.jpeg'}}} const res = await tcb.invokeextension ("CloudInfinite", {
      action:'WaterMark',
      cloudPath: "demo.jpeg"Absolute path, / / store image, and the TCB. Consistent fileContent uploadFile, / / this field is optional, the file content: Uint8Array | Buffer. Value, indicating image processing during upload; If no, the uploaded image operations:opts}); console.log(JSON.stringify(res.data, null, 4)); } catch (err) { console.log(JSON.stringify(err, null, 4)); } } asyncfunction getWaterMark() {
  try {
    const opts = {rules: [
      {
        fileid: "/watermark/demo_image2_mark.jpeg"Rule: {// Extract watermark processing rules mode: 4,type: 2,
          image: '/mark.jpeg'
        }
      }
    ]}
    const res = await tcb.invokeExtension("CloudInfinite", {
      action:'WaterMark',
      cloudPath: "watermark/demo_image2.jpeg"Opts}); console.log(JSON.stringify(res.data, null, 4)); } catch (err) { console.log(JSON.stringify(err, null, 4)); }}Copy the code

Looking forward to

Cloud development and expansion capabilities in the continuous improvement and support, the future will integrate more capabilities, such as: SMS service, face core, etc., so that developers can easily use cloud resources.

In the future, we will open the extension capability platform so that the cloud applications developed by developers based on cloud resources can also be shared and published on the extension platform, so that the creativity and achievements of developers can reach more people and play a greater value.

About Cloud Development

CloudBase is a product solution of cloud integration. It adopts serverless architecture, eliminates operation and maintenance transactions such as environment construction, supports one cloud and multiple terminals, and helps to quickly build small programs, Web applications and mobile applications.

  • Technical documentation: www.cloudbase.net/
  • Wechat search: Tencent Cloud Development, get the latest progress of the project