Intervention / image

PHP Image Processing
https://image.intervention.io
MIT License
13.78k stars 1.5k forks source link

Arabic Letter #775

Open netcase911 opened 6 years ago

netcase911 commented 6 years ago

Hello ,

when I try to generated image the Arabic letter appear in not correct position show like ( Mirrored) for example it show like LTR , how I can fix this issue please ? kindly check the code in below

public function preview($id, Request $request)
{
    $msg = Message::find( $id );
    $string = wordwrap($msg->body,38,"|");
    $strings = explode("|",$string);
    $size = 42;
    $img = Image::canvas(500, 500, '#' . env('SHARE_IMAGE_BACKGROUND_COLOR') );
    $img->insert( storage_path('app/private/share-image.png') );
    $i = ( 500 - ( count( $strings) * ( $size + 2 ) ) ) / 2;
    foreach( $strings AS $s )
    {
        $img->text($s, 250, $i, function($font) {
            $font->file(storage_path('app/private/font.ttf') );
            $font->size(42);
            $font->color('#000000');
            $font->align('center');
            $font->valign('center');
        });
        $i = $i + ( $size - 1);
    }
    $img->text( env('APP_DOMAIN'), 15, 478, function($font) {
        $font->file(storage_path('app/private/font.ttf') );
        $font->size(40);
        $font->color('#ffffff');
    });
    return $img->response('png', 70);
}

/*
public function profile($username, Request $request)
{
    $user = User::where('username', $username)->first();

    $img = Image::make( storage_path('app/private/profile-image.png'));

    $img->text( 'leave me anonymous feedback', 250, 45, function($font) {
        $font->file(storage_path('app/private/font.ttf') );
        $font->size(50);
        $font->color('#ffffff');
        $font->align('center');
        $font->valign('center');
    });

    $img->insert( $user->image ? url('/uploads/images/'.$user->image) : 'http://via.placeholder.com/200x200/2c3e50/ffffff?text=no+image', 'center-center');

    $img->text( $username.'.'.env('APP_DOMAIN'), 250, 455, function($font) {
        $font->file(storage_path('app/private/font.ttf') );
        $font->size(38);
        $font->color('#ffffff');
        $font->align('center');
        $font->valign('center');
    });

    return $img->response('png', 75);
}
*/`
soheylfarzane commented 3 months ago

You can revers array of letters