I need to get the base64 data from photos sotred in a google photo album i own.
I'm accessing the google photo album throught the google photo api. I'm selecting a photo (using either the baseUrl either the productUrl). I'm "sending" this photo to a canvas HTMLElement. When i'm using the toDataUrl function, i'm facing an issue related to CORS : ERROR DOMException: Failed to execute 'toDataURL' on 'HTMLCanvasElement': Tainted canvases may not be exported.
I try to add the crossorigin property in the img tag but the result is not better... crossorigin="anonymous" don't allow me to display my photo... crossorigin='use-credentials" has the same result, but in this case, i don't know how to define the credentials...
component.html :
<div *ngIf="photos" class="divPhotos">
<img *ngFor="let photo of photos" class="photo" [src]="photo.baseUrl" height="200" [alt]="photo.filename" (click)="selectPhoto(photo)" [id]="photo.filename">
<canvas id="canvas"></canvas>
</div>
component.ts :
const img = document.getElementById(photo.filename);
const canvas = document.getElementById('canvas');
// @ts-ignore
const ctx = canvas.getContext('2d');
// @ts-ignore
ctx.drawImage(img, 0, 0);
// @ts-ignore
dataURL = canvas.toDataURL();
Is there a way to get the base64 data from a google photo?