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


    https://platform.openai.com/assistants

    1. from PIL import Image
    2. # Load the uploaded image file
    3. uploaded_image_path = '/mnt/data/file-emzFTaKdEuPE5vGaRzG2zeBx'
    4. # Open the image file
    5. with Image.open(uploaded_image_path) as img:
    6. # Convert the image to grayscale (black and white)
    7. bw_img = img.convert('L')
    8. # Save the new black and white image
    9. bw_image_path = '/mnt/data/black_and_white_image.jpg'
    10. bw_img.save(bw_image_path)
    11. bw_image_path

    1. const Jimp = require('jimp');
    2. // Path to your input color image
    3. const colorImagePath = '/path/to/your/color/image.jpg';
    4. // Path to where you want to save the black and white image
    5. const blackWhiteImagePath = '/path/to/save/black/white/image.jpg';
    6. Jimp.read(colorImagePath)
    7. .then(image => {
    8. // Convert the image to grayscale (black and white)
    9. return image
    10. .grayscale() // this method applies the grayscale effect
    11. .write(blackWhiteImagePath); // save the black and white image
    12. })
    13. .catch(err => {
    14. console.error('Error processing the image:', err);
    15. });
    1. //测试
    2. const chatTest = async (req, res) => {
    3. // Path to your input color image
    4. const colorImagePath = '/temp/ai/file/1.png'
    5. // Path to where you want to save the black and white image
    6. const blackWhiteImagePath = '/temp/ai/file/1_1.png'
    7. Jimp.read(colorImagePath)
    8. .then((image) => {
    9. // Convert the image to grayscale (black and white)
    10. return image
    11. .grayscale() // this method applies the grayscale effect
    12. .write(blackWhiteImagePath) // save the black and white image
    13. })
    14. .catch((err) => {
    15. console.error('Error processing the image:', err)
    16. })
    17. res.send({
    18. code: 200,
    19. data: {},
    20. message: '成功',
    21. })
    22. }

    参考链接:

    https://chat.xutongbao.top/

     

  • 相关阅读:
    如何写一个中间件的springboot的starter?
    IntelliJ IDEA【前端必备插件】
    JetBrains ReSharper Ultimate 2023.2.2
    【云计算与数据中心规划】【期末复习题】
    RPC初识
    Lingo保姆级安装教程及新手快速入门指南
    算法刷题-动态规划-1
    LAMP架构部署
    TCP到底有多厉害?
    详解:网络虚拟化卸载加速技术的演进
  • 原文地址:https://blog.csdn.net/xutongbao/article/details/134507774