openai assistants(机器人助理)彩色图片转黑白
  KvevbRuwqC1X 2023年12月15日 39 0


https://platform.openai.com/assistants

openai assistants(机器人助理)彩色图片转黑白_Image

openai assistants(机器人助理)彩色图片转黑白_Image_02

openai assistants(机器人助理)彩色图片转黑白_Image_03

openai assistants(机器人助理)彩色图片转黑白_Image_04

openai assistants(机器人助理)彩色图片转黑白_机器人_05

from PIL import Image

# Load the uploaded image file
uploaded_image_path = '/mnt/data/file-emzFTaKdEuPE5vGaRzG2zeBx'

# Open the image file
with Image.open(uploaded_image_path) as img:
    # Convert the image to grayscale (black and white)
    bw_img = img.convert('L')
    
    # Save the new black and white image
    bw_image_path = '/mnt/data/black_and_white_image.jpg'
    bw_img.save(bw_image_path)

bw_image_path

openai assistants(机器人助理)彩色图片转黑白_Image_06

const Jimp = require('jimp');

// Path to your input color image
const colorImagePath = '/path/to/your/color/image.jpg';

// Path to where you want to save the black and white image
const blackWhiteImagePath = '/path/to/save/black/white/image.jpg';

Jimp.read(colorImagePath)
  .then(image => {
    // Convert the image to grayscale (black and white)
    return image
      .grayscale() // this method applies the grayscale effect
      .write(blackWhiteImagePath); // save the black and white image
  })
  .catch(err => {
    console.error('Error processing the image:', err);
  });
//测试
const chatTest = async (req, res) => {
    // Path to your input color image
    const colorImagePath = '/temp/ai/file/1.png'

    // Path to where you want to save the black and white image
    const blackWhiteImagePath = '/temp/ai/file/1_1.png'

    Jimp.read(colorImagePath)
      .then((image) => {
        // Convert the image to grayscale (black and white)
        return image
          .grayscale() // this method applies the grayscale effect
          .write(blackWhiteImagePath) // save the black and white image
      })
      .catch((err) => {
        console.error('Error processing the image:', err)
      })

    res.send({
      code: 200,
      data: {},
      message: '成功',
    })
  
}

openai assistants(机器人助理)彩色图片转黑白_机器人_07

openai assistants(机器人助理)彩色图片转黑白_Image_08

openai assistants(机器人助理)彩色图片转黑白_机器人_09

openai assistants(机器人助理)彩色图片转黑白_Image_10


【版权声明】本文内容来自摩杜云社区用户原创、第三方投稿、转载,内容版权归原作者所有。本网站的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@moduyun.com

  1. 分享:
最后一次编辑于 2023年12月15日 0

暂无评论

推荐阅读
KvevbRuwqC1X