1. Go to this page and download the library: Download pteal79/image-annotator library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
pteal79 / image-annotator example snippets
use Pteal79\ImageAnnotator\Facades\ImageAnnotator;
ImageAnnotator::open(
imagePath: $localPath, // ring) $jobImageId, //
namespace App\NativeComponents;
use Illuminate\Support\Facades\File;
use Native\Mobile\Attributes\On;
use Native\Mobile\Edge\NativeComponent;
use Pteal79\ImageAnnotator\Events\ImageAnnotationCancelled;
use Pteal79\ImageAnnotator\Events\ImageAnnotationFailed;
use Pteal79\ImageAnnotator\Events\ImageAnnotationSaved;
use Pteal79\ImageAnnotator\Facades\ImageAnnotator;
class JobPhoto extends NativeComponent
{
public int $imageId;
public function annotate(): void
{
ImageAnnotator::open(
imagePath: storage_path("app/job-images/{$this->imageId}.jpg"),
originalPath: storage_path("app/job-images/{$this->imageId}-original.jpg"),
id: (string) $this->imageId,
);
}
#[On(ImageAnnotationSaved::class)]
public function saved(string $id = '', string $outputPath = '', int $width = 0, int $height = 0, bool $reverted = false): void
{
if ($id !== (string) $this->imageId) {
return;
}
File::move($outputPath, storage_path("app/job-images/{$id}.jpg"));
// Queue the upload here.
}
#[On(ImageAnnotationCancelled::class)]
public function cancelled(string $id = ''): void {}
#[On(ImageAnnotationFailed::class)]
public function failed(string $id = '', string $message = ''): void
{
// Show $message.
}
}
bash
# Creates app/Providers/NativeServiceProvider.php if you do not have it yet
php artisan vendor:publish --tag=nativephp-plugins-provider
php artisan native:plugin:register pteal79/image-annotator
php artisan native:plugin:validate
php artisan native:install --force
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.