@michaelnguyen547
I think this was my total code for dealing with the image that was passed from the slim-equipped form;
$slim = json_decode($request->photo);
$img = $this->imageManager->make($slim->output->image);
$img->save(storage_path() . '/app/public/cropped/photo-' . $member->legacyid . '.jpg');
$img->resize(150,200)
->resizeCanvas(170,220,'center')
->resizeCanvas(0,5,'top',true)
->text($member->fullname,10,220, function ($font) {
$font->file(2);
$font->size(16);
})
->save(storage_path() . '/app/public/bordered/photo-' . $member->legacyid . '.jpg');
$this->imageManager is an instance of Intervention library
most of the code is involved in making a canvas a little larger than the image onto which I can write the members name.
Form
<div class="col-xs-2">
<div class="slim photoShadow" id="cropper"
data-force-size="300,400"
data-filter-sharpen="15"
data-default-input-name="photo"
data-instant-edit="true"
data-will-remove="imageWillBeRemoved"
@if($member->hasPhoto) data-edit="false" @else data-edit="true" @endif
data-label="{{ __('Click or drag image to here to add profile photo') }}"
>
<input type="file" accept="image/jpeg, image/gif, image/png"/>
@if($member->hasPhoto)
<img src="{{ $member->photoUnrestricted }}" />
@endif
</div>
<input type="hidden" name="photoDeleted" id="photoDeleted" value="0" />
<script>
function imageWillBeRemoved(data, remove) {
if (window.confirm("Are you sure? This will completely delete the member's photo. Photo is not removed until you Save this page.")) {
remove();
$('#photoDeleted').val(1);
}
}
</script>
</div>