nlk/image-editor 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

nlk/image-editor

Composer 安装命令:

composer require nlk/image-editor

包简介

A Laravel package for an advanced image editor.

README 文档

README

A powerful, customizable, and easy-to-integrate Image Editor package for Laravel. Provide your users with professional image editing capabilities directly within your application UI, without relying on external tabs or heavy desktop software.

Laravel Image Editor PHP 8.0+

🚀 Features

  • Full Canvas Control: Move, scale, and rotate the main image and any added objects freely.
  • Background Operations: Support for changing canvas background to transparent, solid colors, stunning gradients, or uploaded images.
  • Crop Tool: Interactive visual cropping.
  • Drawing & Eraser: Freehand drawing with adjustable brush size and colors.
  • Text & Typography: Add rich text with custom typography (font family, size, colors, bold, italic).
  • Shapes & Stickers: Insert rectangles, circles, triangles, arrows, and a rich library of pre-defined emojis/stickers.
  • Image Filters: Apply various photo filters like Grayscale, Sepia, Vintage, Invert, along with sliders for Brightness, Contrast, Saturation, and Blur.
  • AI Integration Ready: Built-in UI controls and loading states for AI background removal and image upscaling (AI processing logic must be provided by the host application's backend).
  • History Management: Comprehensive Undo and Redo functionality.
  • Localization: Out-of-the-box support for English, Arabic, and Turkish. Fully customizable via Laravel's translation system.

📦 Installation

This package is designed to be easily plugged into any Laravel 8+ project.

Require the package via Composer:

composer require nlk/image-editor

Publishing Assets

The package contains Blade components, Javascript files, and Translations. Publish them into your application using:

# Publish everything (JS, Views, Translations)
php artisan vendor:publish --provider="Nlk\ImageEditor\ImageEditorServiceProvider"

# OR publish specifically by tags:
php artisan vendor:publish --tag=nlk-image-editor-assets
php artisan vendor:publish --tag=nlk-image-editor-views
php artisan vendor:publish --tag=nlk-image-editor-lang

Note: Don't forget to push the scripts stack in your main layout to render the package's javascript files correctly. The package pushes scripts to the @push('js') stack.

🧑‍💻 Usage

1. Render the Editor Component

Place the component tag anywhere in your blade view. This renders the hidden editor modal structure.

<x-nlk::image-editor />

2. Configure JavaScript Environment

The editor relies on a global variable for identifying where to route AI processing requests (if you use them). Make sure you define it before the scripts are loaded:

<script>
    window.processImageUrl = "{{ route('your.ai.processing.route') }}";
</script>

3. Initialize the Widget (HTML Elements)

The package provides a helper NLKImageWidget.initWidget() to easily bind the editor to standard file inputs.

Blade HTML example:

<!-- Upload area -->
<label for="my_image_input">Upload Image</label>
<input type="file" id="my_image_input" accept="image/*" style="display:none;" />

<!-- Hidden input to store the final Base64 edited image -->
<input type="hidden" name="image_cropped" id="my_image_cropped" value="">

<!-- Preview area -->
<div id="my_image_preview" style="display:none;">
    <img id="my_image_preview_img" src="" alt="Preview">
    <button type="button" id="my_edit_image_btn" style="display:none;">Edit Image</button>
</div>

JavaScript Initialization:

document.addEventListener('DOMContentLoaded', function() {
    NLKImageWidget.initWidget({
        fileInputId: 'my_image_input',
        croppedInputId: 'my_image_cropped',
        previewImgId: 'my_image_preview_img',
        previewDivId: 'my_image_preview',
        editBtnId: 'my_edit_image_btn',
    });
});

4. Opening the Editor Manually (API)

If you have a custom UI flow, you can invoke the editor manually by passing a Base64 string payload:

NLKImageEditor.open(currentBase64Image, function (editedBase64String) {
    // Callback executed when the user clicks 'Save' in the editor
    document.getElementById('my_image_cropped').value = editedBase64String;
    document.getElementById('my_image_preview_img').src = editedBase64String;
});

🧠 AI Endpoint Structure

If you wish to use the AI Background Remover and AI Upscaler UI buttons, your Laravel route (window.processImageUrl) should accept a POST request with the following JSON payload:

{
    "action": "remove_bg",  // or "upscale"
    "image": "data:image/png;base64,....." // Original image base64
}

And it must return a JSON response containing the processed base64 image:

{
    "success": true,
    "image": "data:image/png;base64,....."
}

🌐 Translations

Translations are located in resources/lang/vendor/nlk/ after running vendor:publish. You can modify the translated strings for en, ar, and tr directly in your host application without altering the core package.

🛡️ License

This package is open-source software built for NLKMenu frameworks.

nlk/image-editor 适用场景与选型建议

nlk/image-editor 是一款 基于 JavaScript 开发的 Composer 扩展包,目前已累计 48 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 03 月 03 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 nlk/image-editor 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 nlk/image-editor 我们能提供哪些服务?
定制开发 / 二次开发

基于 nlk/image-editor 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 48
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: JavaScript

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-03-03