Laravel Magika – AI 기반 파일 형식 감지

hackernews | | 📦 오픈소스
#tip
원문 출처: hackernews · Genesis Park에서 요약 및 분석

요약

라라벨 Magika AI 패키지는 구글의 딥러닝 모델을 활용해 파일 확장자가 아닌 내용을 기반으로 99% 이상의 정확도로 파일 유형을 식별합니다. 이 도구는 100개 이상의 형식을 지원하며, PDF, 이미지 등을 지정하거나 최소 신뢰도 점수를 설정하여 업로드를 제한하는 보안 기능을 제공합니다.

본문

Laravel Magika AI is a high-performance file type detection package for Laravel. It utilizes Google's Magika deep learning model to accurately identify file types based on their content rather than extensions. - AI-Powered: Uses Google's deep learning model (Magika) for 99%+ accuracy. - Fast and Lightweight: Inference takes only a few milliseconds per file. - Support for 100+ Formats: Accurately detects code, documents, archives, and media. - Security Focused: Detects misleading extensions (e.g., PHP code disguised as a JPG). - Confidence Scoring: Require a minimum AI confidence score before accepting uploads. Install the package via composer: composer require megoxv/laravel-magika Download and install the appropriate Magika binary for your system: php artisan magika:install Check the installation status anytime: php artisan magika:install --status Use the magika rule in your controllers. You can specify allowed labels and an optional minimum confidence score. // Simple usage (allow only PDF) $request->validate([ 'document' => 'required|file|magika:pdf' ]); // With Confidence Threshold (e.g., must be 95% sure it's a PDF) $request->validate([ 'document' => 'required|file|magika:pdf,0.95' ]); // Multiple types $request->validate([ 'profile_image' => 'required|file|magika:png,jpeg,0.9' ]); use Megoxv\LaravelMagika\Facades\Magika; $result = Magika::predict($path); echo $result->label; // e.g., "pdf" echo $result->mimeType; // e.g., "application/pdf" echo $result->score; // e.g., 0.992 echo $result->isText; // true/false $result = magika()->predict($path); Publish the config file: php artisan vendor:publish --tag="magika-config" The MIT License; see LICENSE for details.

Genesis Park 편집팀이 AI를 활용하여 작성한 분석입니다. 원문은 출처 링크를 통해 확인할 수 있습니다.

공유

관련 저널 읽기

전체 보기 →